0

I have a web application that is deployed using WildFly server 9.x in azure server.

I am moving files using inputstream to outputstream.
while copying files I am having the IOException while uploading the very large file (45 GB).

Caused by: java.io.IOException: Invalid argument
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(FileInputStream.java:255)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    at org.apache.commons.vfs2.util.MonitorInputStream.read(MonitorInputStream.java:99)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)

pseudo code :

byte[] baBuf = new byte[bufferSize];
while ((int iLen = is.read(baBuf)) >= 0) {
    os.write(baBuf, 0, iLen);
    size += iLen;
}

where we had taken specific buffersize of 1048576 (1024 * 1024)
is : InputStream
os : OutputStream

This code is working for the small files.

  • 2
    it's likely a problem with the file system – Stultuske Jun 01 '22 at 05:34
  • *This code is working for the small files.* - maybe not enough space for big files? – Scary Wombat Jun 01 '22 at 05:35
  • 3
    It’s irritating that you’re saying “while moving files” when showing a copying loop. To move files, you should use [`Files.move(…)`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#move(java.nio.file.Path,java.nio.file.Path,java.nio.file.CopyOption...)). Even for copying, you should consider using a [built-in method](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#copy(java.io.InputStream,java.nio.file.Path,java.nio.file.CopyOption...)) – Holger Jun 01 '22 at 10:17
  • We can't explain the behavior of pseudo-code. Show us the real code, including the code that is opening the stream you are reading from. – Stephen C Jun 02 '22 at 11:28
  • Could `bufferSize` be zero? – Maurice Perry Jun 02 '22 at 11:31
  • @MauricePerry the bufferSize could not be zero as it is an constant, – Abhay Patel Jun 06 '22 at 13:08

0 Answers0