0
아파치 commons VFS를 사용하여 sftp의 원격 Linux 시스템으로 파일을 전송하고 있습니다.공유 서버를 사용하여 원격 서버 디스크 공간을 확인하십시오. VFS
전송하기 전에 원격 컴퓨터의 디스크 공간을 확인할 수 있습니까? 디스크 공간의 80 % 미만이 가득 차면 파일을 전송하고 싶습니다.
File file = new File(localFilePath);
if (!file.exists())
throw new RuntimeException("Error. Local file not found");
StandardFileSystemManager manager = new StandardFileSystemManager();
try {
manager.init();
// Create local file object
FileObject localFile = manager.resolveFile(file.getAbsolutePath());
// Create remote file object
FileObject remoteFile = manager.resolveFile(createConnectionString(hostName, username, password, remoteFilePath), createDefaultOptions());
// Copy local file to sftp server
remoteFile.copyFrom(localFile, Selectors.SELECT_SELF);
System.out.println("File upload success");
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
manager.close();
}
덕분에, 바라 스