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 save another input notepad file in bin to give it as input to code. Execute this code n give dat file name...bt its showng File nt found..watz rong in dis...plz help me asap...!!
import java.io.*;
import java.net.*;
class TestofFile
{
public static void main(String args[]) throws Exception
{
int i = 0;
String s2 = new String();
System.out.prin tln("Enter file name:");
BufferedReader br0 = new BufferedReader( new InputStreamRead er(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.prin tln(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.prin tln(s1);
}
}
import java.io.*;
import java.net.*;
class TestofFile
{
public static void main(String args[]) throws Exception
{
int i = 0;
String s2 = new String();
System.out.prin tln("Enter file name:");
BufferedReader br0 = new BufferedReader( new InputStreamRead er(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.prin tln(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.prin tln(s1);
}
}
Comment