byteArray = resource.getBody().getBytes(resource.getEncoding()); rawStream = new ByteArrayInputStream(byteArray); return new InputStreamReader(rawStream, resource.getEncoding()); throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);
/** * Get an InputStream so that the Runtime can build a template with it. * * @param name name of template to get. * @return InputStream containing the template. * @throws ResourceNotFoundException Ff template not found in the RepositoryFactory. */ public InputStream getResourceStream(final String name) throws ResourceNotFoundException { if (StringUtils.isEmpty(name)) { throw new ResourceNotFoundException("No template name provided"); } StringResource resource = this.repository.getStringResource(name); if (resource == null) { throw new ResourceNotFoundException("Could not locate resource '" + name + "'"); } byte[] byteArray = null; try { byteArray = resource.getBody().getBytes(resource.getEncoding()); return new ByteArrayInputStream(byteArray); } catch (UnsupportedEncodingException ue) { throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue); } }
byteArray = resource.getBody().getBytes(resource.getEncoding()); return new ByteArrayInputStream(byteArray); throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);
byteArray = resource.getBody().getBytes(resource.getEncoding()); return new ByteArrayInputStream(byteArray); throw new VelocityException("Could not convert String using encoding " + resource.getEncoding(), ue);