Convert SmbFile to Java IO File

后端 未结 5 1268
隐瞒了意图╮
隐瞒了意图╮ 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 17:02

    It's just a matter of structure I guess, with SmbFile we have two arguments while with File we have just one argument. So, my Idea is to declare a File with the same path of the SmbFile and try to handle your file. For example, in my I want to delete recursively the content of my folder :

    SmbFile sFile = new SmbFile(path, auth)
    
    if (sFile.exists()) {
     File file = new File(path);
     deleteDirectory(file);
    

    }

     boolean deleteDirectory(File directoryToBeDeleted) {
        File[] allContents = directoryToBeDeleted.listFiles();
        if (allContents != null) {
            for (File file : allContents) {
                deleteDirectory(file);
            }
        }
        return directoryToBeDeleted.delete();
    }
    

    I hope this peace of code help you, and sorry for my english !

提交回复
热议问题