use of java.io.PrintStream in project buck by facebook.
the class DirtyPrintStreamDecoratorTest method testPrintlnFloat.
@Test
public void testPrintlnFloat() {
PrintStream delegate = createMock(PrintStream.class);
float value = 2.718f;
delegate.println(value);
delegate.close();
EasyMock.expectLastCall().anyTimes();
replay(delegate);
try (DirtyPrintStreamDecorator dirtyPrintStream = new DirtyPrintStreamDecorator(delegate)) {
dirtyPrintStream.println(value);
verify(delegate);
assertTrue(dirtyPrintStream.isDirty());
}
}
use of java.io.PrintStream in project stetho by facebook.
the class APODDumperPlugin method dump.
@Override
public void dump(DumperContext dumpContext) throws DumpException {
PrintStream writer = dumpContext.getStdout();
Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();
String command = ArgsHelper.nextOptionalArg(argsIter, null);
if (CMD_LIST.equalsIgnoreCase(command)) {
doList(writer);
} else if (CMD_DELETE.equalsIgnoreCase(command)) {
doRemove(writer, argsIter);
} else if (CMD_CLEAR.equalsIgnoreCase(command)) {
doClear(writer);
} else if (CMD_REFRESH.equalsIgnoreCase(command)) {
doRefresh(writer);
} else {
usage(writer);
if (command != null) {
throw new DumpUsageException("Unknown command: " + command);
}
}
}
use of java.io.PrintStream in project stetho by facebook.
the class HprofDumperPlugin method dump.
@Override
public void dump(DumperContext dumpContext) throws DumpException {
final PrintStream output = dumpContext.getStdout();
Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();
String outputPath = argsIter.hasNext() ? argsIter.next() : null;
if (outputPath == null) {
usage(output);
} else {
if ("-".equals(outputPath)) {
handlePipeOutput(output);
} else {
File outputFile = new File(outputPath);
if (!outputFile.isAbsolute()) {
outputFile = mContext.getFileStreamPath(outputPath);
}
writeHprof(outputFile);
output.println("Wrote to " + outputFile);
}
}
}
use of java.io.PrintStream in project gocd by gocd.
the class BuildOutputLogger method consumeLine.
public synchronized void consumeLine(String line) {
if (data == null) {
throw new RuntimeException("No log file specified");
}
PrintStream out = null;
try {
out = new PrintStream(new FileOutputStream(data, true));
out.println(line);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}
use of java.io.PrintStream in project XobotOS by xamarin.
the class FileURLConnection method getDirectoryListing.
/**
* Returns the directory listing of the file component as an input stream.
*
* @return the input stream of the directory listing
*/
private InputStream getDirectoryListing(File f) {
String[] fileList = f.list();
ByteArrayOutputStream bytes = new java.io.ByteArrayOutputStream();
PrintStream out = new PrintStream(bytes);
out.print("<title>Directory Listing</title>\n");
out.print("<base href=\"file:");
out.print(f.getPath().replace('\\', '/') + "/\"><h1>" + f.getPath() + "</h1>\n<hr>\n");
int i;
for (i = 0; i < fileList.length; i++) {
out.print(fileList[i] + "<br>\n");
}
out.close();
return new ByteArrayInputStream(bytes.toByteArray());
}
Aggregations