Hello. I am trying to read the number of lines in a file using this function
[CODE=java]
static int NumberofLines(S tring file) throws IOException{
RandomAccessFil e reader = null;
int lineCount = 0;
try {
reader = new RandomAccessFil e(file + "/perso.txt", "r");
for (String line = reader.readLine (); line != null;
line = reader.readLine ()) {
lineCount++;
}
} catch (IOException e) {
System.err.form at("Could not read %s: %s%n", file, e);
System.exit(1);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {}
}
}
System.out.prin tln("Number of Lines are " + lineCount);
return lineCount;
}
[/CODE]
However I get the following error when I try and run my program I get the following error: -
Could not read \\10.10.0.127\c $\Documents and Settings\oshono wo\My Documents\Chams to be burnt
FIDELITY_ChamsF iles_2007112810 04: java.io.FileNot FoundException: \\10.10.0.127\c $\Documents and Settings\oshono wo\My Documents\Chams to be burnt
FIDELITY_ChamsF iles_2007112810 04\perso.txt (The filename, directory name, or volume label syntax is incorrect)
Java Result: 1
I have shared the folder oshonowo on the 10.10.0.127 machine.
Pls help
[CODE=java]
static int NumberofLines(S tring file) throws IOException{
RandomAccessFil e reader = null;
int lineCount = 0;
try {
reader = new RandomAccessFil e(file + "/perso.txt", "r");
for (String line = reader.readLine (); line != null;
line = reader.readLine ()) {
lineCount++;
}
} catch (IOException e) {
System.err.form at("Could not read %s: %s%n", file, e);
System.exit(1);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {}
}
}
System.out.prin tln("Number of Lines are " + lineCount);
return lineCount;
}
[/CODE]
However I get the following error when I try and run my program I get the following error: -
Could not read \\10.10.0.127\c $\Documents and Settings\oshono wo\My Documents\Chams to be burnt
FIDELITY_ChamsF iles_2007112810 04: java.io.FileNot FoundException: \\10.10.0.127\c $\Documents and Settings\oshono wo\My Documents\Chams to be burnt
FIDELITY_ChamsF iles_2007112810 04\perso.txt (The filename, directory name, or volume label syntax is incorrect)
Java Result: 1
I have shared the folder oshonowo on the 10.10.0.127 machine.
Pls help
Comment