I want to read the password protected network shared drive text files in java. Below is my code:
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("\\VMDEV0715\drive\myfile.txt"));
String line = reader.readLine();
while (line != null) {
System.out.println(line);
// read next line
line = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
} catch (AccessDeniedException e1) {
e1.printStackTrace();
} finally {
reader.close();
}
While reading the file am always getting the Access denied exception. I want to read that file in different user login id. How to do it in java?