Convert SmbFile to Java IO File

后端 未结 5 1304
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 16:37

My Java application requires access to a large excel file (1GB+ in size) saved on remote shared folder. I\'m using SmbFile to get the file with authenticati

5条回答
  •  悲哀的现实
    2021-01-02 16:51

    Using Apache Commons IO library

    https://mvnrepository.com/artifact/commons-io/commons-io

    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", "user", "key");
    
    SmbFile smbFile = new SmbFile("smb://IP/pitoka.tmp", auth)
    
    InputStream initialStream = smbFile.getInputStream();
    
    File targetFile = new File("/tmp/pitoka.tmp");
    
    FileUtils.copyInputStreamToFile(initialStream, targetFile);
    

    I hope help you.

提交回复
热议问题