• Post Reply Bookmark Topic Watch Topic
  • New Topic

2GB file returning 0 length

 
Sue Fish
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Sue Fish
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!