473,411 Members | 2,083 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,411 software developers and data experts.

plz help..nt locating file

here is a java code, wich is supposed to read a file name from user n read its contents and display it, bt its nt working..ne1 dere cud help me...jus copy n paste dis code in a notepad file wid name TsetofFile.java n also save a file havng sum text notepad file in bin to give it as input. Execute it n give dat file name...bt its showng File nt found..watz rong in dis...plz help me asap...!!


import java.io.*;

class TestofFile
{
public static void main(String args[]) throws Exception
{
int i = 0;
String s2 = new String();
System.out.println("Enter file name:");
BufferedReader br0 = new BufferedReader(new InputStreamReader(System.in));
char c = 0;
do
{
c = (char) br0.read();
s2 = s2 + c;
i++;
} while (c != '\n' );
s2 = s2.substring(0,i-1);
System.out.println(s2);
FileInputStream file = new FileInputStream(s2);
String s1 = new String();
char f = 0;
do
{
f = (char) file.read();
s1 = s1 + f;
} while (f != '\n' );
System.out.println(s1);
}
}
Jul 13 '07 #1
1 1145
r035198x
13,262 8TB
here is a java code, wich is supposed to read a file name from user n read its contents and display it, bt its nt working..ne1 dere cud help me...jus copy n paste dis code in a notepad file wid name TsetofFile.java n also save a file havng sum text notepad file in bin to give it as input. Execute it n give dat file name...bt its showng File nt found..watz rong in dis...plz help me asap...!!


import java.io.*;

class TestofFile
{
public static void main(String args[]) throws Exception
{
int i = 0;
String s2 = new String();
System.out.println("Enter file name:");
BufferedReader br0 = new BufferedReader(new InputStreamReader(System.in));
char c = 0;
do
{
c = (char) br0.read();
s2 = s2 + c;
i++;
} while (c != '\n' );
s2 = s2.substring(0,i-1);
System.out.println(s2);
FileInputStream file = new FileInputStream(s2);
String s1 = new String();
char f = 0;
do
{
f = (char) file.read();
s1 = s1 + f;
} while (f != '\n' );
System.out.println(s1);
}
}
Do not double post. Refer to your previous thread and continue the discussion there.
Jul 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jonathan Gennick | last post by:
Alex Martelli, Anna Ravenscroft, and I are trying to locate the following people, whose Actionstate Python Cookbook recipes we are wishing to use in the second, printed edition of the Python...
0
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
2
by: Good Man | last post by:
Hi there folks I've got an interesting little problem going on. On one of my projects, I have users log in to retrieve files. The files themselves are stored outside of the www directory on...
0
by: dmlinliverpool | last post by:
I am running VS.net 2005 Express and Sql Server 2005 Express. The DB and VS are both on the same PC. I cannot connect to a database from within VS. In Database Explorer I click Connect To...
9
by: Morris Neuman | last post by:
Im working with VS 2005 and trying to use a Hyperlink field in a datagrid to play a wave file that is not located in the website folders but is in a plain folder on the same machine, windows 2003...
1
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
1
by: =?Utf-8?B?TWF5?= | last post by:
We are getting WebForm_DoPostBackWithOptions is not defined and other Java script errors related to WebResource.axd file. I narrowed down the problem and found out the cause but can't come up with...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.