use of java.io.CharArrayWriter in project android_frameworks_base by DirtyUnicorns.
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 android_frameworks_base by DirtyUnicorns.
the class VolumeInfo 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 jdk8u_jdk by JetBrains.
the class DriverManagerTests method tests18.
/**
* Create a PrintWriter and use to to send output via DriverManager.println
* Validate that if you disable the writer, the output sent is not present
*/
@Test
public void tests18() throws Exception {
CharArrayWriter cw = new CharArrayWriter();
PrintWriter pw = new PrintWriter(cw);
DriverManager.setLogWriter(pw);
assertTrue(DriverManager.getLogWriter() == pw);
DriverManager.println(results[0]);
DriverManager.setLogWriter(null);
assertTrue(DriverManager.getLogWriter() == null);
DriverManager.println(noOutput);
DriverManager.setLogWriter(pw);
DriverManager.println(results[1]);
DriverManager.println(results[2]);
DriverManager.println(results[3]);
DriverManager.setLogWriter(null);
DriverManager.println(noOutput);
/*
* Check we do not get the output when the stream is disabled
*/
BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()));
for (String result : results) {
assertTrue(result.equals(reader.readLine()));
}
}
use of java.io.CharArrayWriter in project intellij-community by JetBrains.
the class Base64 method encode.
public static char[] encode(byte[] content) {
CharArrayWriter cw = new CharArrayWriter((4 * content.length) / 3);
int idx = 0;
int x = 0;
for (int i = 0; i < content.length; i++) {
if (idx == 0)
x = (content[i] & 0xff) << 16;
else if (idx == 1)
x = x | ((content[i] & 0xff) << 8);
else
x = x | (content[i] & 0xff);
idx++;
if (idx == 3) {
cw.write(alphabet[x >> 18]);
cw.write(alphabet[(x >> 12) & 0x3f]);
cw.write(alphabet[(x >> 6) & 0x3f]);
cw.write(alphabet[x & 0x3f]);
idx = 0;
}
}
if (idx == 1) {
cw.write(alphabet[x >> 18]);
cw.write(alphabet[(x >> 12) & 0x3f]);
cw.write('=');
cw.write('=');
}
if (idx == 2) {
cw.write(alphabet[x >> 18]);
cw.write(alphabet[(x >> 12) & 0x3f]);
cw.write(alphabet[(x >> 6) & 0x3f]);
cw.write('=');
}
return cw.toCharArray();
}
use of java.io.CharArrayWriter in project intellij-community by JetBrains.
the class XMLOutputterTest method printElement.
private String printElement(Element root) throws IOException {
XMLOutputter xmlOutputter = JDOMUtil.createOutputter("\n");
final Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true);
xmlOutputter.setFormat(format);
CharArrayWriter writer = new CharArrayWriter();
xmlOutputter.output(root, writer);
String res = new String(writer.toCharArray());
return res;
}
Aggregations