Shawn,


>private void test(FormFile file) throws Exception
>{
>
>                     //retrieve the content type
>                     String contentType = file.getContentType();
>
>                     //retrieve the file data
>                     ByteArrayOutputStream baos = new
>ByteArrayOutputStream();
>                     InputStream stream = file.getInputStream();
>                     byte[] buffer = new byte[file.getFileSize()];
>
>                     stream.read(buffer);
>                     baos.write(buffer);
>
>                     //write the file to the file specified
>                     OutputStream bos = new
>FileOutputStream("C:\\test\\book.txt");
>
>                      int bytesRead = 0;
>
>                     while ((bytesRead = stream.read(buffer, 0,
>                              buffer.length)) != -1)

One problem seems to be here.  You're referencing "stream", which has
already been
read into the ByteArrayOutputStream above.  The stream will already be empty
and
return -1.

You probably want to do something like this:

byte[] dataChunk = baos.getBytes();
bos.write(dataChunk, 0, dataChunk.length)

Reply via email to