wood burning stoves 2.0*
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
Author

OutputStream gets a IndexOutOfBoundsException

Arthur Burma
Greenhorn

Joined: Nov 12, 2009
Posts: 16
Hi,

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 java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:260)
at eu.europa.schengen.dataengine.enginerunner.Main.copyXSD(Main.java:94)
at eu.europa.schengen.dataengine.enginerunner.Main.main(Main.java:49)


Thanks for any help;

Regards,

NB.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Nov 12, 2009
Posts: 16
Hi,

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 :



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OutputStream gets a IndexOutOfBoundsException
 
Similar Threads
Unzipping a .zip file containing .gif files
extract directory from current jar
how to read files in a directory on a local network
Java And OpenDocument Files
using byte array to copy contents of one file to another