Example #1
0
  public static void main(String[] args) throws Exception {

    File blah = File.createTempFile("blah", null);
    blah.deleteOnExit();
    ByteBuffer[] dstBuffers = new ByteBuffer[10];
    for (int i = 0; i < 10; i++) {
      dstBuffers[i] = ByteBuffer.allocateDirect(10);
      dstBuffers[i].position(10);
    }
    FileInputStream fis = new FileInputStream(blah);
    FileChannel fc = fis.getChannel();

    // No space left in buffers, this should return 0
    long bytesRead = fc.read(dstBuffers);
    if (bytesRead != 0) throw new RuntimeException("Nonzero return from read");

    fc.close();
    fis.close();
  }
Example #2
0
 public static void main(String[] args) throws Exception {
   blah = File.createTempFile("blah", null);
   blah.deleteOnExit();
   initTestFile(blah);
   try {
     out.println("Test file " + blah + " initialized");
     testZero();
     out.println("Zero size: OK");
     testRead();
     out.println("Read: OK");
     testWrite();
     out.println("Write: OK");
     testHighOffset();
     out.println("High offset: OK");
     testExceptions();
     out.println("Exceptions: OK");
   } finally {
     blah.delete();
   }
 }