File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes 2GB file returning 0 length Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "2GB file returning 0 length" Watch "2GB file returning 0 length" New topic
Author

2GB file returning 0 length

Sue Fish
Greenhorn

Joined: Aug 29, 2001
Posts: 7
I am on a Sun, using JDK1.2.2.
I am trying to list the files & sizes in a directory. When using tmpFile = File(fn) the length (long)
len = tmpFile.length()
comes back 0 on the 2GB+ file. (It works correctly on a SGI!?)
Also, the tmpFile.isFile comes back false on Sun, true on SGI ?!
Also, at Sun command line: file fn returns " c program text "
(this is a binary file)
Any suggestions or idea's are greatly appreciated. I found some info on Sun website on a File io bug that was supposed to be fixed for 1.2(?)
Thanks,
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18652
Very strange. I don't know the cause of your problem. But here are a few things you can check, which may help:
What happens if you print out the value of tmpFile.exists()? How about tmpFile.getAbsolutePath()? Does it match the actual location of the file? What if you try to open a new InputStream(tmpFile)? Can you read the file?
If the file in question was created recently using Java - was the output stream flushed? Was it closed?
Good luck, and let us know how you progress...


"I'm not back." - Bill Harding, Twister
Sue Fish
Greenhorn

Joined: Aug 29, 2001
Posts: 7
Thanks for your response. I had tried all the File methods and on the Sun, tmpFile.exists=false, tmpFile.length()=0.
On the SGI they were correct.
On the Sun & SGI the .getAbsolutePath were correct.
When I create a new FileInputStream(fn) I throw an exception, FileNotFound: not enough memory for data type' ONLY on the Sun.
The same code runs fine on a SGI, opening in/out streams, reading, writing (to a new file) & closing both 2GB files.
We are looking at the Sun O/S and also installing a newer version of Java. I'm still trying to establish if this is a known bug or not, or if there is a workaround.
Thanks again...
Sue
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18652
Ah, here we are:
http://developer.java.sun.com/developer/bugParade/bugs/4203706.html
This was reported in 1.2.2 for Solaris, and fixed in Kestrel beta - meaning 1.3.0 beta. So a shiny new JVM should make the problem go away.
Sue Fish
Greenhorn

Joined: Aug 29, 2001
Posts: 7
Ah! I found the same bug yesterday! Thanks for confirming my thoughts - it's always nice to have a second set of hands to bounce ideas and point places, (also to confirm that I'm not crazy!)
Now I need a workaround while I convince them to upgrade the JVM!!
Thanks again,
Sue
 
 
subject: 2GB file returning 0 length
 
Threads others viewed
IRIX JRE 1.5?
Need help in configuring Sun one Web Server 6.1 with weblogic 8.1
WAS3.5 AIX Segmentation Fault Problem
How to configure in obj.conf, Failover of cluster in Weblogic
jstl.jar
IntelliJ Java IDE