aboutsummaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/LargeFile.java
diff options
context:
space:
mode:
authorBryce McKinlay <mckinlay@redhat.com>2004-07-15 00:58:41 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2004-07-15 01:58:41 +0100
commitb845ed9ff8113d47c2a38dda58f234e35c89508e (patch)
treef575402da639d9a031536021ae9a3b419a674da1 /libjava/testsuite/libjava.lang/LargeFile.java
parent018479fbada08df57b9978ec7f01c06d81e08554 (diff)
downloadgcc-b845ed9ff8113d47c2a38dda58f234e35c89508e.zip
gcc-b845ed9ff8113d47c2a38dda58f234e35c89508e.tar.gz
gcc-b845ed9ff8113d47c2a38dda58f234e35c89508e.tar.bz2
re PR libgcj/16204 (File I/O fails on files >= 2^31 bytes (2GB))
2004-07-14 Bryce McKinlay <mckinlay@redhat.com> PR libgcj/16204 * Makefile.am (AM_CXXFLAGS): Add -D_FILE_OFFSET_BITS=64 to enable large file support. * Makefile.in: Rebuilt. * testsuite/libjava.lang/LargeFile.java: New test case. * testsuite/libjava.lang/LargeFile.out: New file. From-SVN: r84733
Diffstat (limited to 'libjava/testsuite/libjava.lang/LargeFile.java')
-rw-r--r--libjava/testsuite/libjava.lang/LargeFile.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.lang/LargeFile.java b/libjava/testsuite/libjava.lang/LargeFile.java
new file mode 100644
index 0000000..1bb8aec
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/LargeFile.java
@@ -0,0 +1,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();
+ }
+ }
+}