Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FileInputStream Exception - Bad file descriptor

 
David Law
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I am trying to learn about compression and have fallen at the first hurdle. The following code gzip's files:



... but I get the following errors:

Exception in thread "main" java.io.IOException: Bad file descriptor
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:177)
at Compressor.gzipFile(Compressor.java:16)
at Compressor.main(Compressor.java:28)

One site I visited said it was a bug in Java but the code wasn't quite the same. If anyone could point me in the right direction I'd be very grateful. Thank you.

BTW I am using jdk 1.6 on Linux.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's a bug in Java.



Shouldn't it be like something like this:
 
David Law
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhhhh of course.

Thank you very much Freddy!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!