This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes OutputStream gets a  IndexOutOfBoundsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "OutputStream gets a  IndexOutOfBoundsException" Watch "OutputStream gets a  IndexOutOfBoundsException" New topic

OutputStream gets a IndexOutOfBoundsException

Arthur Burma

Joined: Nov 12, 2009
Posts: 16

I try to copy an xsd file from a mvn project structure (the resource is in /template folder), so that , when I launch jar, the Main calls the xsd and copies it to current directory (outside the jar):

But when main method calls CopyXSD(), this returns an exception:

Exception in thread "main" java.lang.IndexOutOfBoundsException
at Method)
at eu.europa.schengen.dataengine.enginerunner.Main.copyXSD(
at eu.europa.schengen.dataengine.enginerunner.Main.main(

Thanks for any help;



Paul Clapham

Joined: Oct 14, 2005
Posts: 19728

Your call to the "write" method is outside the while-loop and therefore you are calling it when len is -1.
Arthur Burma

Joined: Nov 12, 2009
Posts: 16

as there is a test in while loop for positive values only, it can't write outside while loop.
But, i've found another way, much more simpler :

Have you checked out Aspose?
subject: OutputStream gets a IndexOutOfBoundsException
It's not a secret anymore!