How to read password protected share drive file in java

时间:2019-04-08 12:58:46

标签: java java-8

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?

0 个答案:

没有答案