jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Accessing File from other computer in network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing File from other computer in network" Watch "Accessing File from other computer in network" New topic

Accessing File from other computer in network

Jonk kulsh

Joined: Feb 04, 2005
Posts: 7
I'm getting problem in accessing file from other computer in the network. computer drive is shareble.

import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

public class ReadWriteTextFile {

private static void doReadWriteTextFile() {

try {

// input/output file names
String inputFileName = "\\\\C:\\demo.java";
String outputFileName = "C:\\Demo\\demo1.java";

// Create FileReader Object
FileReader inputFileReader = new FileReader(inputFileName);
FileWriter outputFileReader = new FileWriter(outputFileName);

// Create Buffered/PrintWriter Objects
BufferedReader inputStream = new BufferedReader(inputFileReader);
PrintWriter outputStream = new PrintWriter(outputFileReader);

// Keep in mind that all of the above statements can be combined
// into the following:
//BufferedReader inputStream = new BufferedReader(new FileReader("README_InputFile.txt"));
//PrintWriter outputStream = new PrintWriter(new FileWriter("ReadWriteTextFile.out"));

outputStream.println("+---------- Testing output to a file ----------+");

String inLine = null;

while ((inLine = inputStream.readLine()) != null) {

outputStream.println("+---------- Testing output to a file ----------+");


} catch (IOException e) {




public static void main(String[] args) {


Error i'm getting

java.io.FileNotFoundException: \\C:\demo.java (The filename, director
y name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at java.io.FileReader.<init>(FileReader.java:41)
at ReadWriteTextFile.doReadWriteTextFile(ReadWriteTextFile.java:19)
at ReadWriteTextFile.main(ReadWriteTextFile.java:57)
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
In ...

... you needed four back-slashes at the start. That's because you really want two back-slashes, but you need an extra back-slash to "escape" each one.

Of course, such a path only works in the world of Windows. Have you considered using "file:" URLs instead, which might be more portable?

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link: http://aspose.com/file-tools
subject: Accessing File from other computer in network
It's not a secret anymore!