It's the first time I post, I don't know what this problem boils down to. The project framework is ssh, so let me talk about my problem here! I hope you will forgive me~
The customer uploads pictures (color) to ftp through the instrument, and when I download the pictures to the local area, it becomes black and white~ May I ask what is the situation? The function of file download is normal, and the file can also be read, that is, the file is black and white after downloading, what is going on? please help! ! ! !
ByteArrayOutputStream buffOut=null;
FileOutputStream fos = null;
InputStream is = null;
try{
// Step 1: Set basic properties
//Set FTPClient to passive transmission mode to solve thread hang problem
ftpClient.enterLocalPassiveMode();
ftpClient.setBufferSize(100000 );
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
buffOut=new ByteArrayOutputStream();
ftpClient.retrieveFile(remoteFileName, buffOut);
FTPFile [] ftp = ftpClient.listFiles(remoteFileName);
File file = new File(localFileName);
fos = new FileOutputStream(file);
// Step 2: Get the input stream of the remote file
is = ftpClient.retrieveFileStream(remoteFileName);
// If the input stream is not empty, the remote The input stream of the file is written to the local
byte[] buffer = new byte[1024];
int i = -1;
while ((i = is.read(buffer)) != -1) {
fos.write(buffer, 0, i);
}
}
Question about file download
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326861684&siteId=291194637
Recommended
Ranking