0
누구든지이 코드의 문제점을 볼 수 있습니까? 진행률 막대를 표시하지 않지만 모든 파일을 업로드합니다. 나는 체크 아웃 썬 튜토리얼과 스윙 워커도 만들었지 만 아직 해결하지 못했습니다.ProgressMonitorInputStream을 ftp 업로드에 추가하는 방법은 무엇입니까?
private static boolean putFile(String m_sLocalFile, FtpClient m_client) {
boolean success = false;
int BUFFER_SIZE = 10240;
if (m_sLocalFile.length() == 0) {
System.out.println("Please enter file name");
}
byte[] buffer = new byte[BUFFER_SIZE];
try {
File f = new File(m_sLocalFile);
int size = (int) f.length();
System.out.println("File " + m_sLocalFile + ": " + size + " bytes");
System.out.println(size);
FileInputStream in = new FileInputStream(m_sLocalFile);
//test
InputStream inputStream = new BufferedInputStream(
new ProgressMonitorInputStream(null,"Uploading " + f.getName(),in));
//test
OutputStream out = m_client.put(f.getName());
int counter = 0;
while (true) {
int bytes = inputStream.read(buffer); //in
if (bytes < 0)
break;
out.write(buffer, 0, bytes);
counter += bytes;
System.out.println(counter);
}
out.close();
in.close();
inputStream.close();
success =true;
} catch (Exception ex) {
System.out.println("Error: " + ex.toString());
}
return true;
}
당신이 옳습니다. 작업이 진행 막대가 필요하기에 충분하지 않습니다. – itro