• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Elliot Harold I/O problem

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please help...already well googled! (New to java.)

Going through said book, stuck on chapter 6....FileDumper2 program.

Would someone please download and try to compile these (link below):

1. FileDumper2
2. HexFilter
3. DecimalFilter
4. DumpFilter
5. BufferedStreamCopier from Chapter 6 (6.4)

They will compile but am getting ArrayIndexOutOfBoundsException when try to run Hex and Decimal (ASCII runs ok).
Just cannot see it.
Problem in the fill() method methinks......fill() calls read() calls fill()......

Thanks in advance.

(http://www.cafeaulait.org/books/javaio2/ioexamples/06/index.html)

C:\Users\john\Desktop\CODE>java FileDumper2 -d FileThree.txt
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.elharo.io.DumpFilter.read(DumpFilter.java:26)
at com.elharo.io.DumpFilter.read(DumpFilter.java:53)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.elharo.io.BufferedStreamCopier.copy(BufferedStreamCopier.java:23)
at FileDumper2.dump(FileDumper2.java:54)
at FileDumper2.main(FileDumper2.java:29)


C:\Users\john\Desktop\CODE>java FileDumper2 -a FileThree.txt
This is a test.
C:\Users\john\Desktop\CODE>
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Can you please supply
a) the exception stack trace
b) the input you're giving

I've just tried it (after making the buffer and index fields of DumpFilter non-private to get it to compile) and it's working just fine.
 
Sean Mac Eoin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help,

Instead of making the variables non-private I copied them into HexFilter and DecimalFilter files and it all compiled ok (obviously stupid ...since its a different array and variable ), maybe that's where the problem is.

If I make them public instead perhaps they will run.

Will try it.

Thanks
 
Sean Mac Eoin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Worked !

Thanks.
 
Rob Spoor
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic