473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cannot read from file

Hello. I am trying to read the number of lines in a file using this function

Expand|Select|Wrap|Line Numbers
  1. static int NumberofLines(String file) throws IOException{
  2.         RandomAccessFile reader = null;
  3.         int lineCount = 0;    
  4.         try {
  5.             reader = new RandomAccessFile(file + "/perso.txt", "r");
  6.             for (String line = reader.readLine(); line != null;
  7.                     line = reader.readLine()) {
  8.                 lineCount++;
  9.             }
  10.         } catch (IOException e) {
  11.             System.err.format("Could not read %s: %s%n", file, e);
  12.             System.exit(1);
  13.         } finally {
  14.             if (reader != null) {
  15.                 try {
  16.                     reader.close();
  17.                 } catch (IOException e) {}
  18.             }
  19.         }
  20.         System.out.println("Number of Lines are " + lineCount);
  21.         return lineCount;
  22.     }
  23.  
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\oshonowo\My Documents\Chams to be burnt
FIDELITY_ChamsFiles_200711281004: java.io.FileNotFoundException: \\10.10.0.127\c$\Documents and Settings\oshonowo\My Documents\Chams to be burnt
FIDELITY_ChamsFiles_200711281004\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
Dec 4 '07 #1
2 2148
JosAH
11,448 Expert 8TB
Read the error text: a file name cannot contain IP addresses or host names.
Use a URL instead given that name, connect it and get an InputStream from that
connection. Start at the API documentation for the URL class.

kind regards,

Jos
Dec 4 '07 #2
The file could contain an ip address using the previous run time environment. This program ran using an ip address and was working before. Is it the change in run time environment that caused this?
Dec 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
1
by: Fie Fie Niles | last post by:
I have IIS installed on XP Professional workstation machine. I have an ASP page that open connection to an Access database, then when trying to update the database, it gave me the error "cannot...
2
by: Joerg Battermann | last post by:
Hello there, I was wondering how I can check whether I am allowed to read a certain file or not? Some of e.g. XP's files are not readable, not even by the Administrator, and when trying to open...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
2
by: Jill | last post by:
Hi I am using ms acces 2002 to read an xml file. I am using the DOM object in ms access - version xml 4 with service pack 2. here is the start of the code below. But I am having trouble reading...
3
by: JeffM | last post by:
I have a .dat file on a remote server that seems to be locked. I have tried to FTP to it and delete it, rename it, copy over it and I get the error. "Could not copy temporary files to the output...
15
by: waltbrad | last post by:
Hello. I'm studying the book "C++ Primer Plus" by Stephan Prata. In chapter 6 he gives an exercise that reads from a file. The list is thus: 4 Sam Stone 2000 Freida Flass 100500 Tammy...
21
by: Mick1000 | last post by:
Hi all, I am new to perl and this forum. I am trying to setup a mailing list subscription functionality for customers to receive a periodic newsletter from me. My perl program grabs the html form...
1
by: tanya.wang | last post by:
I want to access files from a remote server so I mapped it in my server under z:\ for \\myserver\web\mysite\images\ I added this UNC path to my IIS virtual directory and name it as "upload" but I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.