summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/LargeFile.java
blob: 1bb8aec8c2674b557d9297f172276b9ed3d69462 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Test to ensure files >= 2^31 bytes are supported. */

import java.io.*;

public class LargeFile
{
  public static void main(String[] args) throws IOException
  {
    File file = new File("LargeFile.tmp");

    try
      {
	RandomAccessFile rfile = new RandomAccessFile(file, "rw");

	long pos = (long) Math.pow(2, 31);

	rfile.seek(pos);
	rfile.write('O');
	rfile.write('K');
	rfile.close();

	// Re-open, read byte back using FileInputStream and clean up.

	FileInputStream fis = new FileInputStream(file);
	fis.skip(pos);
	System.out.print((char) fis.read());
	System.out.println((char) fis.read());
	fis.close();
      }
    finally
      {
        if (file.exists())
	  file.delete();
      }
  }
}