Refine search
@Override public void write( File output, Map<String, Object> options, Model model ) throws IOException { Objects.requireNonNull( output, "output cannot be null" ); Objects.requireNonNull( model, "model cannot be null" ); output.getParentFile().mkdirs(); write( WriterFactory.newXmlWriter( output ), options, model ); }
/** * Create a new Writer with specified encoding. * * @param file not null file. * @param encoding not null supported encoding. * @return a writer instance for the output file using the given encoding. * @throws UnsupportedEncodingException if any. * @throws FileNotFoundException if any. * @see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html">Supported encodings</a> */ public static Writer newWriter( File file, String encoding ) throws UnsupportedEncodingException, FileNotFoundException { return newWriter( new FileOutputStream( file ), encoding ); } }
protected static void writeXmlFile( File output, String content ) throws IOException { Writer out = null; try { output.getParentFile().mkdirs(); out = WriterFactory.newXmlWriter( output ); out.write( content ); out.close(); out = null; } finally { IOUtil.close( out ); } } }
/** * Writes a StringBuilder into a file. * * @param outFile The file to read. * @param input The contents of the file. * @throws IOException when things go wrong. */ protected final void writeFile( File outFile, StringBuilder input ) throws IOException { Writer writer = WriterFactory.newXmlWriter( outFile ); try { IOUtil.copy( input.toString(), writer ); } finally { IOUtil.close( writer ); } }
String initialcontent = IOUtil.toString( in ); out = WriterFactory.newXmlWriter( outputFile ); IOUtil.copy( content, out ); IOUtil.close( in ); IOUtil.close( out );
/** * Write the given string to a file. * * @param str the str * @param file the file * @throws IOException Signals that an I/O exception has occurred. */ private void writeStringToFile(String str, File file) throws IOException { if (!file.exists() && file.isDirectory()) { return; } BufferedWriter bw = null; try { bw = new BufferedWriter(WriterFactory.newWriter(file, this.encoding)); bw.write(str); } finally { IOUtil.close(bw); } }
reader = ReaderFactory.newXmlReader( originalFile ); reader = new InterpolationFilterReader( reader, composite, "@", "@" ); xml = IOUtil.toString( reader ); IOUtil.close( reader ); writer = WriterFactory.newXmlWriter( interpolatedFile ); writer.write( xml ); writer.flush(); IOUtil.close( writer );
new InterpolationFilterReader( ReaderFactory.newXmlReader( originalFile ), composite, "@", "@" ) ) xml = IOUtil.toString( reader ); try ( Writer writer = WriterFactory.newXmlWriter( interpolatedFile ) )
private void writeTemplate( String template, File file, Context context ) throws ModelloException { try { Writer writer = getEncoding() == null ? WriterFactory.newPlatformWriter( file ) : WriterFactory.newWriter( file, getEncoding() ); velocity.getEngine().mergeTemplate( template, context, writer ); writer.flush(); writer.close(); } catch ( Exception e ) { throw new ModelloException( "Error while generating code.", e ); } } }
try jsw = new JSourceWriter( WriterFactory.newPlatformWriter( file ) );
writer = WriterFactory.newXmlWriter( targetFile ); XSTREAM.toXML( webappStructure, writer ); writer.close(); IOUtil.close( writer );
/** * Writes a StringBuilder into a file. * * @param outFile The file to read. * @param input The contents of the file. * @throws IOException when things go wrong. */ protected final void writeFile( File outFile, StringBuilder input ) throws IOException { Writer writer = WriterFactory.newXmlWriter( outFile ); try { IOUtil.copy( input.toString(), writer ); } finally { IOUtil.close( writer ); } }
String initialcontent = IOUtil.toString( in ); out = WriterFactory.newXmlWriter( outputFile ); IOUtil.copy( content, out ); IOUtil.close( in ); IOUtil.close( out );
/** * Write content into the given javaFile and using the given encoding. * All line separators will be unified. * * @param javaFile not null * @param encoding not null * @param content not null * @throws IOException if any */ private static void writeFile( final File javaFile, final String encoding, final String content ) throws IOException { Writer writer = null; try { writer = WriterFactory.newWriter( javaFile, encoding ); writer.write( StringUtils.unifyLineSeparators( content ) ); writer.close(); writer = null; } finally { IOUtil.close( writer ); } }
reader = ReaderFactory.newXmlReader( originalFile ); reader = new InterpolationFilterReader( reader, composite, "@", "@" ); xml = IOUtil.toString( reader ); IOUtil.close( reader ); writer = WriterFactory.newXmlWriter( interpolatedFile ); writer.write( xml ); writer.flush(); IOUtil.close( writer );
/** * Create a new java source file writer, with configured encoding. * * @param packageName the package of the source file to create * @param className the class of the source file to create * @return a JSourceWriter with configured encoding * @throws IOException */ protected JSourceWriter newJSourceWriter( String packageName, String className ) throws IOException { String directory = packageName.replace( '.', File.separatorChar ); File f = new File( new File( getOutputDirectory(), directory ), className + ".java" ); if ( !f.getParentFile().exists() ) { f.getParentFile().mkdirs(); } OutputStream os = getBuildContext().newFileOutputStream( f ); Writer writer = ( getEncoding() == null ) ? WriterFactory.newPlatformWriter( os ) : WriterFactory.newWriter( os, getEncoding() ); return new JSourceWriter( writer ); }
try jsw = new JSourceWriter( WriterFactory.newPlatformWriter( file ) );
private void write( File metadataFile, Metadata metadata ) throws RepositoryException { Writer writer = null; try { metadataFile.getParentFile().mkdirs(); writer = WriterFactory.newXmlWriter( metadataFile ); new MetadataXpp3Writer().write( writer, metadata ); } catch ( IOException e ) { throw new RepositoryException( "Could not write metadata " + metadataFile + ": " + e.getMessage(), e ); } finally { IOUtil.close( writer ); } }
IOUtil.close( is ); IOUtil.close( fileReader ); IOUtil.close( fileReader ); try out = WriterFactory.newXmlWriter( parentPomFile ); IOUtil.copy( w.toString(), out );