use of java.io.CharArrayWriter in project robovm by robovm.
the class CharArrayWriterTest method testCharArrayWriter.
public void testCharArrayWriter() throws Exception {
String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
CharArrayWriter a = new CharArrayWriter();
CharArrayWriter b = new CharArrayWriter();
a.write(str, 0, 26);
a.write('X');
a.writeTo(b);
assertEquals(27, a.size());
assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzX", a.toString());
b.write("alphabravodelta", 5, 5);
b.append('X');
assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoX", b.toString());
b.append("omega");
assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoXomega", b.toString());
}
use of java.io.CharArrayWriter in project robovm by robovm.
the class OldCharArrayWriterTest method test_ConstructorI.
public void test_ConstructorI() {
// Test for method java.io.CharArrayWriter(int)
cw = new CharArrayWriter(90);
assertEquals("Test 1: Incorrect writer created.", 0, cw.size());
try {
cw = new CharArrayWriter(-1);
fail("IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
}
use of java.io.CharArrayWriter in project XobotOS by xamarin.
the class NetworkStats method toString.
@Override
public String toString() {
final CharArrayWriter writer = new CharArrayWriter();
dump("", new PrintWriter(writer));
return writer.toString();
}
use of java.io.CharArrayWriter in project platform_frameworks_base by android.
the class DiskInfo method toString.
@Override
public String toString() {
final CharArrayWriter writer = new CharArrayWriter();
dump(new IndentingPrintWriter(writer, " ", 80));
return writer.toString();
}
use of java.io.CharArrayWriter in project frostwire by frostwire.
the class IOUtils method toCharArray.
/**
* Get the contents of an <code>InputStream</code> as a character array
* using the specified character encoding.
* <p>
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param is the <code>InputStream</code> to read from
* @param encoding the encoding to use, null means platform default
* @return the requested character array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs
* @since 2.3
*/
public static char[] toCharArray(InputStream is, Charset encoding) throws IOException {
CharArrayWriter output = new CharArrayWriter();
copy(is, output, encoding);
return output.toCharArray();
}
Aggregations