Java Code Examples for com.googlecode.totallylazy.Files#write()
The following examples show how to use
com.googlecode.totallylazy.Files#write() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebConsoleResource.java From java-repl with Apache License 2.0 | 6 votes |
@POST @Hidden @Path("snap") @Produces(MediaType.APPLICATION_JSON) public Response snap(@FormParam("id") String id) { Option<WebConsoleClientHandler> clientHandler = agent.client(id); if (!clientHandler.isEmpty()) { String snapId = UUID.randomUUID().toString(); Files.write(clientHandler.get().history().toString("\n").getBytes(), snapFile(snapId)); return ok() .entity(emptyMap(String.class, Object.class) .insert("snap", snapId) .insert("uri", snapUri(snapId).toString()) ); } else { return response(BAD_REQUEST); } }
Example 2
Source File: FileRenderer.java From yatspec with Apache License 2.0 | 5 votes |
@Override public void complete(File yatspecOutputDir, Result result) throws Exception { final File output = outputFile(yatspecOutputDir, result); output.delete(); output.getParentFile().mkdirs(); String content = render(result); Files.write(content.getBytes("UTF-8"), output); System.out.println("Yatspec output:\n" + output); }
Example 3
Source File: TreeVisualiser.java From totallylazy with Apache License 2.0 | 5 votes |
private void render(TreeMap<?, ?> map) { final File file = new File(Files.temporaryDirectory(), getClass().getSimpleName() + ".html"); Files.write(bytes("<html><head><style>" + ".tree { border: 1px solid grey; padding: 0 1px; } " + ".key { text-align: center; } " + ".tree, .left, .right { display: table-cell; }" + "</style></head><body>" + new TreeMapRenderer().render(map) + "</body></html>"), file); System.out.println("tree = " + file); }
Example 4
Source File: ConsoleHistory.java From java-repl with Apache License 2.0 | 5 votes |
public boolean save() { if (file.isEmpty()) return false; try { Files.write(history.toString("\n").getBytes(), file.get()); return true; } catch (Exception e) { return false; } }