[Java] Reading a file on a network drive

Asked by Boipelo Mawasha

I'm attempting to read a file I created on a network drive. The problem is that in Eclipse, I specified my path as:

path = "\\\\sever\\folder\\folder\\file.txt"

I get the following output:

java.io.IOException: Failed to open file:////server/folder/folder/file.txt. Error message: The parameter is incorrect.

The code is use to open the file is as follows:

public void OpenFile() {
  try {
  if (Desktop.isDesktopSupported()){
   desktop = Desktop.getDesktop();
  }

   desktop.open(new File(path));

  } catch (IOException e) {
   System.out.println("File could not be opened");
   e.printStackTrace();
  }
 }

ReadTextFromFile rtff = new ReadTextFromFile(path);

rtff.OpenFile();

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

what about using:

path = "//server/folder/folder/file.txt"

Revision history for this message
Boipelo Mawasha (bmawasha) said :
#2

Thanks RaiMan, that solved my question.