Search in sources :

Example 26 with CharArrayWriter

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());
}
Also used : CharArrayWriter(java.io.CharArrayWriter)

Example 27 with CharArrayWriter

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.
    }
}
Also used : CharArrayWriter(java.io.CharArrayWriter)

Example 28 with CharArrayWriter

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();
}
Also used : CharArrayWriter(java.io.CharArrayWriter) PrintWriter(java.io.PrintWriter)

Example 29 with CharArrayWriter

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();
}
Also used : CharArrayWriter(java.io.CharArrayWriter) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 30 with CharArrayWriter

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();
}
Also used : CharArrayWriter(java.io.CharArrayWriter)

Aggregations

CharArrayWriter (java.io.CharArrayWriter)211 PrintWriter (java.io.PrintWriter)51 IOException (java.io.IOException)39 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)21 Test (org.junit.Test)11 InputStreamReader (java.io.InputStreamReader)9 Map (java.util.Map)9 BufferedReader (java.io.BufferedReader)8 File (java.io.File)8 ArrayList (java.util.ArrayList)8 TitledBorder (javax.swing.border.TitledBorder)8 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)7 Graph (edu.cmu.tetrad.graph.Graph)7 Writable (groovy.lang.Writable)7 CharArrayReader (java.io.CharArrayReader)7 Reader (java.io.Reader)7 Date (java.util.Date)7 InputStream (java.io.InputStream)6 StringReader (java.io.StringReader)6 IKnowledge (edu.cmu.tetrad.data.IKnowledge)5