@Override public void write(int c) throws IOException { if (fill>buffer.length-1) { flush(); } buffer[fill++]=(char)c; }
/** * Writes the Hjson representation of this value to the given writer. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer the writer to write this value to * @param options options for the Hjson format * @throws IOException if an I/O error occurs in the writer */ public void writeTo(Writer writer, HjsonOptions options) throws IOException { if (options==null) throw new NullPointerException("options is null"); WritingBuffer buffer=new WritingBuffer(writer, 128); new HjsonWriter(options).save(this, buffer, 0, "", true); buffer.flush(); }
/** * Writes the Hjson representation of this value to the given writer. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer the writer to write this value to * @param options options for the Hjson format * @throws IOException if an I/O error occurs in the writer */ public void writeTo(Writer writer, HjsonOptions options) throws IOException { if (options==null) throw new NullPointerException("options is null"); WritingBuffer buffer=new WritingBuffer(writer, 128); new HjsonWriter(options).save(this, buffer, 0, "", true); buffer.flush(); }
/** * Writes the JSON/Hjson representation of this value to the given writer using the given formatting. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer the writer to write this value to * @param format controls the formatting * @throws IOException if an I/O error occurs in the writer */ public void writeTo(Writer writer, Stringify format) throws IOException { WritingBuffer buffer=new WritingBuffer(writer, 128); switch (format) { case PLAIN: new JsonWriter(false).save(this, buffer, 0); break; case FORMATTED: new JsonWriter(true).save(this, buffer, 0); break; case HJSON: new HjsonWriter(null).save(this, buffer, 0, "", true); break; } buffer.flush(); }
@Override public void write(int c) throws IOException { if (fill>buffer.length-1) { flush(); } buffer[fill++]=(char)c; }
/** * Writes the JSON/Hjson representation of this value to the given writer using the given formatting. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer the writer to write this value to * @param format controls the formatting * @throws IOException if an I/O error occurs in the writer */ public void writeTo(Writer writer, Stringify format) throws IOException { WritingBuffer buffer=new WritingBuffer(writer, 128); switch (format) { case PLAIN: new JsonWriter(false).save(this, buffer, 0); break; case FORMATTED: new JsonWriter(true).save(this, buffer, 0); break; case HJSON: new HjsonWriter(null).save(this, buffer, 0, "", true); break; } buffer.flush(); }
@Override public void write(char[] cbuf, int off, int len) throws IOException { if (fill>buffer.length-len) { flush(); if (len>buffer.length) { writer.write(cbuf, off, len); return; } } System.arraycopy(cbuf, off, buffer, fill, len); fill += len; }
@Override public void write(char[] cbuf, int off, int len) throws IOException { if (fill>buffer.length-len) { flush(); if (len>buffer.length) { writer.write(cbuf, off, len); return; } } System.arraycopy(cbuf, off, buffer, fill, len); fill += len; }
@Override public void write(String str, int off, int len) throws IOException { if (fill>buffer.length-len) { flush(); if (len>buffer.length) { writer.write(str, off, len); return; } } str.getChars(off, off+len, buffer, fill); fill += len; }
@Override public void write(String str, int off, int len) throws IOException { if (fill>buffer.length-len) { flush(); if (len>buffer.length) { writer.write(str, off, len); return; } } str.getChars(off, off+len, buffer, fill); fill += len; }