2016-09-30 4 views
1

Windows에서 파일을 가지고 있는데이 파일을 리눅스에서 읽고 싶습니다. 아래 코드는 Windows에서 실행하려고 할 때 잘 작동하지만 리눅스에서 실행하려고하면 잘됩니다.아파치 공유 vfs를 사용하여 Windows에서 Linux로 원격 파일을 읽는 방법?

"Could not read from "file:///10.0.0.1/C$/myfolder/test.txt" because it is not a file." 

여기 내 코드가 있습니다.

FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 

    FileObject fo = VFS.getManager().resolveFile(remoteFilePath, opts); 

    InputStream inputStream = fo.getContent().getInputStream(); //this line throws exception 

답변

1

나는 해결책이있을 것이라고 생각합니다.

나는 같은 오류가 발생한이 같은 옵션을 설정하여 해결이 도움이

private void readSFTP(){   
// ... 
final FileObject sftpOriginObj = manager.resolveFile(ftpOrigin, getSFTPOptions()); 
// ... 
} 

    private static FileSystemOptions getSFTPOptions() throws FileSystemException { 
      // Create SFTP options 
      final FileSystemOptions opts = new FileSystemOptions(); 

      // SSH Key checking 
      SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no"); 

      // Using the following line will cause VFS to choose File System's Root 
      // as VFS's root. If I wanted to use User's home as VFS's root then set 
      // 2nd method parameter to "true" 

      // Root directory set to user home 
      SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, false); 

      // Timeout is count by Milliseconds 
      SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 10000); 

      return opts; 
     } 

희망을.