示例#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();
  }
示例#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();
   }
 }
示例#3
0
 public static String temp_filePath(String namePattern, String ext)
     throws IOException, FileNotFoundException {
   File temp = File.createTempFile("temp-file-name", ".tmp");
   return temp.getAbsolutePath();
 }