use of java.io.PrintWriter in project adt4j by sviperll.
the class Throwables method render.
public static String render(Throwable exception) {
StringWriter message = new StringWriter();
PrintWriter writer = new PrintWriter(message);
exception.printStackTrace(writer);
writer.flush();
return message.toString();
}
use of java.io.PrintWriter in project playn by threerings.
the class IOSLog method logImpl.
@Override
protected void logImpl(Level level, String msg, Throwable e) {
Console.WriteLine(level + ": " + msg);
if (e != null) {
try {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
Console.WriteLine(sw.toString());
} catch (Throwable t) {
Console.WriteLine(e);
Console.WriteLine("<stack trace generation failed: " + t + ">");
}
}
}
use of java.io.PrintWriter in project bazel by bazelbuild.
the class BazelBuildCaseTest method testPrepareGeneratedCode_Copy.
@Test
public void testPrepareGeneratedCode_Copy() throws IOException {
Path root = folder.newFolder("PrepareGeneratedCodeCopy").toPath();
// Prepare source
Path source = root.resolve("source");
source.toFile().mkdir();
try (PrintWriter writer = new PrintWriter(source.resolve("file").toFile(), UTF_8.name())) {
writer.println("content");
}
// Prepare destination
Path destination = root.resolve("destination");
destination.toFile().mkdir();
new BazelBuildCase().prepareGeneratedCode(source, destination);
ImmutableSet<String> filenames = fileArrayToImmutableSet(destination.toFile().listFiles());
assertThat(filenames).containsExactly("WORKSPACE", "file");
assertThat(new Scanner(destination.resolve("file")).useDelimiter("\\Z").next()).isEqualTo("content");
}
use of java.io.PrintWriter in project bazel by bazelbuild.
the class BazelBuilderTest method testBuildAndGetElapsedTime.
@Test
public void testBuildAndGetElapsedTime() throws IOException, CommandException {
Path root = folder.newFolder("BuildAndGetElapsedTime").toPath();
Path generatedCode = root.resolve("GeneratedCode");
Files.createDirectories(generatedCode);
// Prepare binary
Path buildBinary = root.resolve("binary.sh");
Files.createFile(buildBinary);
if (!buildBinary.toFile().setExecutable(true)) {
fail("Failed to set executable");
}
double expectedValue = 10.42;
try (PrintWriter writer = new PrintWriter(buildBinary.toFile())) {
writer.format("#!/bin/bash\n>&2 echo 'blah blah Elapsed time: %.2f blah blah'", expectedValue);
}
double result = new BazelBuilder(generatedCode, null).buildAndGetElapsedTime(buildBinary, ImmutableList.<String>of());
assertThat(result).isWithin(EPSILON).of(expectedValue);
}
use of java.io.PrintWriter in project disunity by ata4.
the class DisUnityCli method main.
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
LogUtils.configure();
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true)) {
JCommander jc = new JCommander();
DisUnityRoot root = new DisUnityRoot();
root.init(jc, out);
jc.setProgramName(DisUnity.getProgramName());
jc.addObject(root);
jc.parse(args);
root.run();
} catch (ParameterException ex) {
L.log(Level.WARNING, "Parameter error: {0}", ex.getMessage());
} catch (Throwable t) {
L.log(Level.SEVERE, "Fatal error", t);
}
}
Aggregations