I want to create a zip file with files located in one ftp location and copy this zip file to another ftp location without saving locally.
I can handle this for small file sizes. It works well for small files of 1 mb in size, etc.
But if the file size is large, like 100 MB, 200 MB, 300 MB, then its error output is like,
java.io.FileNotFoundException: STOR myfile.zip : 550 The process cannot access the file because it is being used by another process. at sun.net.ftp.FtpClient.readReply(FtpClient.java:251) at sun.net.ftp.FtpClient.issueCommand(FtpClient.java:208) at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:398) at sun.net.ftp.FtpClient.put(FtpClient.java:609)
My code
URLConnection urlConnection=null; ZipOutputStream zipOutputStream=null; InputStream inputStream = null; byte[] buf; int ByteRead,ByteWritten=0; ***Destination where file will be zipped*** URL url = new URL("ftp://" + ftpuser+ ":" + ftppass + "@"+ ftppass + "/" + fileNameToStore + ";type=i"); urlConnection=url.openConnection(); OutputStream outputStream = urlConnection.getOutputStream(); zipOutputStream = new ZipOutputStream(outputStream); buf = new byte[size]; for (int i=0; i<li.size(); i++) { try { ***Souce from where file will be read*** URL u= new URL((String)li.get(i));
Can someone let me know how I can avoid this error and process large files
source share