use of java.io.BufferedWriter in project jetty.project by eclipse.
the class FileSystemResourceTest method testInputStream.
@Test
public void testInputStream() throws Exception {
Path dir = testdir.getPath().normalize().toRealPath();
Files.createDirectories(dir);
Path file = dir.resolve("foo");
String content = "Foo is here";
try (StringReader reader = new StringReader(content);
BufferedWriter writer = Files.newBufferedWriter(file)) {
IO.copy(reader, writer);
}
try (Resource base = newResource(dir.toFile())) {
Resource foo = base.addPath("foo");
try (InputStream stream = foo.getInputStream();
InputStreamReader reader = new InputStreamReader(stream);
StringWriter writer = new StringWriter()) {
IO.copy(reader, writer);
assertThat("Stream", writer.toString(), is(content));
}
}
}
use of java.io.BufferedWriter in project jetty.project by eclipse.
the class FileSystemResourceTest method testLength.
@Test
public void testLength() throws Exception {
Path dir = testdir.getPath().normalize().toRealPath();
Files.createDirectories(dir);
Path file = dir.resolve("foo");
try (StringReader reader = new StringReader("foo");
BufferedWriter writer = Files.newBufferedWriter(file)) {
IO.copy(reader, writer);
}
long expected = Files.size(file);
try (Resource base = newResource(dir.toFile())) {
Resource res = base.addPath("foo");
assertThat("foo.length", res.length(), is(expected));
}
}
use of java.io.BufferedWriter in project vert.x by eclipse.
the class HttpTest method setupFile.
protected File setupFile(String fileName, String content) throws Exception {
File file = new File(testDir, fileName);
if (file.exists()) {
file.delete();
}
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
out.write(content);
out.close();
return file;
}
use of java.io.BufferedWriter in project jetty.project by eclipse.
the class PropertyUserStoreTest method initUsersText.
private File initUsersText() throws Exception {
Path dir = testdir.getPath().toRealPath();
FS.ensureDirExists(dir.toFile());
File users = dir.resolve("users.txt").toFile();
try (Writer writer = new BufferedWriter(new FileWriter(users))) {
writer.append("tom: tom, roleA\n");
writer.append("dick: dick, roleB\n");
writer.append("harry: harry, roleA, roleB\n");
}
return users;
}
use of java.io.BufferedWriter in project jetty.project by eclipse.
the class ModuleGraphWriter method write.
public void write(Modules modules, Path outputFile) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
PrintWriter out = new PrintWriter(writer)) {
writeHeaderMessage(out, outputFile);
out.println();
out.println("digraph modules {");
// Node Style
out.println(" node [color=gray, style=filled, shape=rectangle];");
out.println(" node [fontname=\"Verdana\", size=\"20,20\"];");
// Graph Style
out.println(" graph [");
out.println(" concentrate=false,");
out.println(" fontname=\"Verdana\",");
out.println(" fontsize = 20,");
out.println(" rankdir = LR,");
out.println(" ranksep = 1.5,");
out.println(" nodesep = .5,");
out.println(" style = bold,");
out.println(" labeljust = l,");
out.println(" label = \"Jetty Modules\",");
out.println(" ssize = \"20,40\"");
out.println(" ];");
List<Module> enabled = modules.getEnabled();
// Module Nodes
writeModules(out, modules, enabled);
// Module Relationships
writeRelationships(out, modules, enabled);
out.println("}");
out.println();
}
}
Aggregations