I can to write a text file from remote pc which contain a share folder without any authentication. But when I try to read file from a share folder with authentication it cannot read the file.the actual file location is
url : 10.11.201.45
Drive : D
username :BELY
password : BELY-du
file location : D://Share_BELY/bb/txt.
Here's my code:
// The name of the file to open.
String fileName = "//10.11.201.45/D$/Share-BELY/BELY:BELY-du@/bb.txt";
String line = null;
try {
// FileReader reads text files in the default encoding.
FileReader fileReader = new FileReader(fileName);
// Always wrap FileReader in BufferedReader.
BufferedReader bufferedReader = new BufferedReader(fileReader);
while((line = bufferedReader.readLine()) != null) {
System.out.println(line);
}
// Always close files.
bufferedReader.close();
}
catch(FileNotFoundException ex) {
System.out.println("Unable to open file '" + fileName + "'");
}
catch(IOException ex) {
System.out.println("Error reading file '" + fileName + "'");
// Or we could just do this:
// ex.printStackTrace();
}