file not found exception

Hi to every one,

I wrote the following program in eclipse environment.the programe has to read from a file called 搊ut.txt?and print it on the screen.but it is giving the following error.if it is not finding the file. then where should I put the file 搊ut.txt?in Eclipse environment.iam also pasting the folder structure.

Exception in thread "main" java.io.FileNotFoundException: out (The system cannot find the file specified)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.<init>(Unknown Source)

at java.io.FileInputStream.<init>(Unknown Source)

at inputoutput.Printing.printing(inputoutput.java:22)

at inputoutput.inputoutput.main(inputoutput.java:46)

the program is

package inputoutput;

import java.io.*;

class Printing implements Runnable{

Thread t;

public void run(){

}

public void printing()throws IOException,FileNotFoundException {

try{

t=new Thread();

t.start();

FileInputStream fileinputstream = new FileInputStream("out");

int value = fileinputstream.read();

while(value!=-1){

System.out.print((char)value);

Thread.sleep(50);

value=fileinputstream.read();

}

fileinputstream.close();

}

catch(InterruptedException e){

System.out.println(e);

}

}

}

public class inputoutput {

/**

* @param args

*/

public static void main(String[] args) throws IOException {

Printing b=new Printing();

b.printing();

}

}

[1611 byte] By [santhosh_thadvaia] at [2007-11-26 23:48:47]
# 1
Your file called out.txt not out.
rym82a at 2007-7-11 15:24:43 > top of Java-index,Java Essentials,Java Programming...
# 2

I'm not sure I understand all the Runnable/Thread stuff. Anyway...

> the programe has to read from a file called “out.txt” and

[snip]

> Exception in thread "main" java.io.FileNotFoundException: out (The system cannot

> find the file specified)

The message says that the runtime cannot find a file called out - it should be

looking for out.txt.

pbrockway2a at 2007-7-11 15:24:43 > top of Java-index,Java Essentials,Java Programming...
# 3

You mentioned that the file name is out.txt. But in the program you have written FileInputStream fileinputstream = new FileInputStream("out");

it should be

FileInputStream fileinputstream = new FileInputStream("out.txt");

If you are using Eclipse then you should put the file in the folder where the src folder is present. The folder structure is:

ProjectFolder

|

| src

||-- your source files.

|

| out.txt

In case you don't have the src folder and the source files is in the ProjectFolder directly then the source files and the out.txt will be in the same directory. In that case the folder structure will be

ProjectFolder

|

| your source files.

|

| out.txt

For further queries plz remember to put the source code using the code tag. This helps others to study your program more correctly

diptaPBa at 2007-7-11 15:24:43 > top of Java-index,Java Essentials,Java Programming...
# 4
thank you very much now the program is working.
santhosh_thadvaia at 2007-7-11 15:24:43 > top of Java-index,Java Essentials,Java Programming...
# 5
thank you very much it is working now.
santhosh_thadvaia at 2007-7-11 15:24:43 > top of Java-index,Java Essentials,Java Programming...