Пример #1
0
  public OutputStream getOutput(String pathname, boolean append, int chunk_size)
      throws IOException {
    GridFile file = (GridFile) getFile(pathname, chunk_size);
    if (!file.createNewFile()) throw new IOException("creation of " + pathname + " failed");

    return new GridOutputStream(file, append, data, chunk_size);
  }
Пример #2
0
  public void testWriteAcrossMultipleChunksWithNonDefaultChunkSizeAfterFileIsExplicitlyCreated()
      throws Exception {
    GridFile file = (GridFile) fs.getFile("multipleChunks.txt", 20); // chunkSize = 20
    file.createNewFile();

    writeToFile(
        "multipleChunks.txt",
        "This text spans multiple chunks, because each chunk is only 20 bytes long.",
        10); // chunkSize = 10 (but it is ignored, because the file was already created with
    // chunkSize = 20

    String text = getContents("multipleChunks.txt");
    assertEquals(
        text, "This text spans multiple chunks, because each chunk is only 20 bytes long.");
  }
Пример #3
0
 public OutputStream getOutput(GridFile file) throws IOException {
   if (!file.createNewFile()) throw new IOException("creation of " + file + " failed");
   return new GridOutputStream(file, false, data, default_chunk_size);
 }