/** * Closes the underlying <code>Reader</code> quietly. * This method is useful if you only want to process the first few * lines of a larger file. If you do not close the iterator * then the <code>Reader</code> remains open. * This method can safely be called multiple times. */ public void close() { finished = true; IOUtils.closeQuietly(bufferedReader); cachedLine = null; }
@Override protected void closeSource( InputStream reader ) { if ( reader != null ) { IOUtils.closeQuietly( reader ); } }
/** * Closes the underlying <code>Reader</code> quietly. This method is useful if you only want to process the first * few lines of a larger file. If you do not close the iterator then the <code>Reader</code> remains open. This * method can safely be called multiple times. */ public void close() { finished = true; IOUtils.closeQuietly( bufferedReader ); cachedLine = null; }
@Override protected void closeSource( InputStream reader ) { if ( reader != null ) { IOUtils.closeQuietly( reader ); } }
public void process(String entryName, IContext context, Reader reader, Writer writer) throws XDocReportException, IOException { try { processNoCache(entryName, context, reader, writer); } finally { if (reader != null) { IOUtils.closeQuietly(reader); } if (writer != null) { IOUtils.closeQuietly(writer); } } }
public static void generateFile( ITemplateEngine templateEngine, String templateName, IContext dumpContext, File javaFile ) throws IOException, XDocReportException { Writer javaWriter = null; try { javaFile.getParentFile().mkdirs(); javaWriter = new FileWriter( javaFile ); templateEngine.process( templateName, dumpContext, javaWriter ); } finally { if ( javaWriter != null ) { IOUtils.closeQuietly( javaWriter ); } } }
public static void generate( ITemplateEngine templateEngine, String templateName, IContext dumpContext, OutputStream out ) throws IOException, XDocReportException { Writer javaWriter = null; try { javaWriter = new OutputStreamWriter( out ); templateEngine.process( templateName, dumpContext, javaWriter ); } finally { if ( javaWriter != null ) { IOUtils.closeQuietly( javaWriter ); } } }
public static void generateDocumentFile( IXDocReport report, InputStream documentIn, IContext dumpContext, File srcDir ) throws FileNotFoundException, IOException { String documentFileName = getDocumentFileName( report, dumpContext ); File documentFile = new File( srcDir, documentFileName ); documentFile.getParentFile().mkdirs(); OutputStream documentOut = null; try { documentOut = new FileOutputStream( documentFile ); IOUtils.copy( documentIn, documentOut ); } finally { if ( documentOut != null ) { IOUtils.closeQuietly( documentOut ); } } }
public void write( OutputStream outputStream ) throws IOException { InputStream inputStream = null; try { inputStream = getInputStream(); IOUtils.copy( inputStream, outputStream ); } finally { IOUtils.closeQuietly( inputStream ); } }
public static void generateFieldsMetadataFile( IXDocReport report, IContext dumpContext, File srcDir ) throws IOException { FieldsMetadata metadata = report.getFieldsMetadata(); if ( metadata != null ) { String xmlFieldsFileName = getXMLFieldsFileName( report, dumpContext ); File xmlFieldsFile = new File( srcDir, xmlFieldsFileName ); xmlFieldsFile.getParentFile().mkdirs(); Writer xmlFieldsWriter = null; try { xmlFieldsWriter = new FileWriter( xmlFieldsFile ); metadata.saveXML( xmlFieldsWriter, true, false ); } finally { if ( xmlFieldsWriter != null ) { IOUtils.closeQuietly( xmlFieldsWriter ); } } } }
public void process( String templateName, IContext context, Writer writer ) throws IOException, XDocReportException { // TODO : Improve it, cache the JavaMainDump.ftl templateName = templateName + ".ftl"; Reader reader = new InputStreamReader( FreemarkerTemplateEngine.class.getResourceAsStream( templateName ) ); try { // Create a new template. Template template = new Template( templateName, reader, getFreemarkerConfiguration() ); // Merge template with Java model process( context, writer, template ); } finally { if ( reader != null ) { IOUtils.closeQuietly( reader ); } } }
IOUtils.closeQuietly( input ); IOUtils.closeQuietly( output );
public static void generateJSONFile( IXDocReport report, IContext context, boolean upperCaseFirstChar, IContext dumpContext, File srcDir ) throws IOException { String jsonFileName = getJSONFileName( report, dumpContext ); JSONObject jsonObject = new JSONObject( context.getContextMap(), upperCaseFirstChar ); File jsonFile = new File( srcDir, jsonFileName ); jsonFile.getParentFile().mkdirs(); Writer jsonWriter = null; try { jsonWriter = new FileWriter( jsonFile ); String json = jsonObject.toString( 1 ); IOUtils.write( json, jsonWriter ); } finally { if ( jsonWriter != null ) { IOUtils.closeQuietly( jsonWriter ); } } }
public void upload( BinaryData data ) throws ResourcesException { String resourceId = data.getResourceId(); byte[] input = data.getContent(); String resourcePath = getResourcePath( resourceId ); File file = new File( getRootFolder(), resourcePath ); if ( !file.getParentFile().exists() ) { file.getParentFile().mkdirs(); } OutputStream output = null; try { output = new FileOutputStream( file ); IOUtils.write( input, output ); } catch ( IOException e ) { throw new ResourcesException( e ); } finally { if ( output != null ) { IOUtils.closeQuietly( output ); } } }
IOUtils.copy( entryInputStream, zipOutputStream ); IOUtils.closeQuietly( entryInputStream ); zipOutputStream.closeEntry();
} finally { if (reader != null) { IOUtils.closeQuietly(reader); IOUtils.closeQuietly(writer);
IOUtils.copy(entryInputStream, zipOutputStream); IOUtils.closeQuietly(entryInputStream); zipOutputStream.closeEntry();
public final void dump( IXDocReport report, InputStream documentIn, IContext context, DumperOptions option, OutputStream out ) throws IOException, XDocReportException { try { ITemplateEngine templateEngine = TemplateEngineRegistry.getRegistry().getTemplateEngine( report.getTemplateEngine().getKind() ); if ( documentIn == null ) { documentIn = DumpHelper.getDocument( report ); } doDump( report, documentIn, context, option, templateEngine, out ); } finally { if ( documentIn != null ) { IOUtils.closeQuietly( documentIn ); } if ( out != null ) { IOUtils.closeQuietly( out ); } } }
IOUtils.closeQuietly( zipOutputStream );
protected void saveBinaryImage( ImageProviderInfo imageProviderInfo ) throws XDocReportException { String entryName = getImageEntryName( imageProviderInfo ); OutputStream out = outputStreamProvider.getEntryOutputStream( entryName ); try { imageProviderInfo.getImageProvider().write( out ); } catch ( IOException e ) { throw new XDocReportException( e ); } finally { IOUtils.closeQuietly( out ); } }