How to read a file from remote system using java?

后端 未结 8 1126
忘了有多久
忘了有多久 2020-12-06 05:18

I have a file copied in one computer and I need to access the file from other computer. I am not sure, which protocol or which technology to use for this? Please provide me

8条回答
  •  渐次进展
    2020-12-06 06:04

    Share the directory and access the file thruogh java code try this one:

    File f = new File("//10.22.33.122/images")
    
    File[] files = f.listFiles(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            // Specify the extentions of files to be included.
            return name.endsWith(".bmp") || name.endsWith(".gif");
        }
    });
    
    // get names of the files
    String[] fileNamesArray = null; 
    for (int indx = 0; indx < files.length(); indx++) {
        fileNamesArray[indx] = files[indx].getName();
    }
    
    return fileNamesArray; 
    

提交回复
热议问题