コード例 #1
0
ファイル: Test.java プロジェクト: pkouki/recsys2015
 private void testFile(DataOutputStream out) throws IOException {
   File file = new File("test.txt");
   if (file.exists()) {
     file.delete();
   }
   RandomAccessFile write = new RandomAccessFile(file, "rws");
   // RandomAccessFile write = new RandomAccessFile(file, "rwd");
   int fileSize = 10 * 1024 * 1024;
   FileUtils.setLength(write, fileSize);
   write.seek(0);
   int i = 0;
   FileDescriptor fd = write.getFD();
   while (true) {
     if (write.getFilePointer() >= fileSize) {
       break;
     }
     write.writeBytes(i + "\r\n");
     fd.sync();
     out.writeInt(i);
     out.flush();
     i++;
   }
   write.close();
 }