다음 JCIFS 코드를 사용하여 로컬 디스크에서 공유 드라이브로 파일을 복사하고 있습니다.
public boolean copyFiles(String srcFilePath, String destinationFileName) throws Exception {
boolean successful = false;
SmbFileOutputStream sfos = null;
try {
String user = USER_NAME + ":" + PASSWORD;
System.out.println("User: " + user);
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("mydomain",USER_NAME,PASSWORD);
Config.setProperty("resolveOrder", "DNS");
String destinationFilePath = NETWORK_FOLDER +"/" +destinationFileName;
SmbFile sFile = new SmbFile(destinationFilePath, auth);
sfos = new SmbFileOutputStream(sFile);
// sfos.write(getBytesFromFile(new File(srcFilePath))); -- 1st approach
// Files.copy(new File(srcFilePath).toPath(),sfos); -- 2nd approach
FileInputStream fis = new FileInputStream(srcFilePath);
BufferedReader brl = new BufferedReader(new InputStreamReader(fis));
String b = null;
while ((b = brl.readLine()) != null) {
sfos.write(b.getBytes());
}
sfos.flush();
successful = true;
System.out.println("Successful" + successful);
} catch (Exception e) {
successful = false;
e.printStackTrace();
} finally {
if (sfos != null) {
sfos.close();
}
}
return successful;
}
10MB 파일을 복사하는 데 10 분 이상 걸립니다. 같은 파일을 직접 복사하면 1 분 정도 걸립니다. 파일을 복사하기 위해 3 가지 방법을 시도했지만 (코드의 주석 처리 된 부분 참조) 어느 것도 큰 차이를 보이지 않았습니다.
어쨌든 JCIFS의 성능을 향상시킬 수 있습니까?
해결 방법으로 공유 드라이브를 마운트하고 해당 드라이브에 파일을 복사했습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다