public static void main(String[] args) throws IOException, URISyntaxException {
String ipaddress = "10.20.220.187";
String folderpath = "C:\\Users\\Administrator\\Desktop\\KS_testData\\";
String fileName = "test.txt";
String inputFileName = "file:\\\\"+ipaddress+"\\"+folderpath+fileName;
System.out.println(" inputFileName "+inputFileName);
File file = new File(inputFileName);
FileReader inputFileReader = new FileReader(file);
BufferedReader inputStream = new BufferedReader(inputFileReader);
String inLine = null;
while ((inLine = inputStream.readLine()) != null) {
System.out.println(inLine);
}
}
Here Im trying to connect to provided ipaddress and read file on it, The specified folder name is a Shared Folder and Im getting FileNotFoundException. Can anyone suggest what Im doing wrong.
Output received is :
inputFileName file:\\10.20.220.187\C:\Users\Administrator\Desktop\KS_testData\test.txt
Exception in thread "main" java.io.FileNotFoundException: file:\10.20.220.187\C:\Users\Administrator\Desktop\KS_testData\test.txt (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileReader.<init>(FileReader.java:72)
at com.sv.ppsdemos.remote.RemoteReadAndWrite.main(RemoteReadAndWrite.java:22)