To use InputStream & OutputStream class and read a data and display a data on command prompt.
CODING
import java.io.*;
public class ReadWrite {
public static void main(String[] args) {
int c;
InputStream istream;
OutputStream ostream;
istream =System.in;
ostream = System.out;
System.out.println("Anything Type");
try{
while((c=istream.read()) !=-1 )
ostream.write(c);
}catch(IOException e){
System.out.println("Error::"+e.getMessage());
}finally {
try{
istream.close();
ostream.close();
}catch(IOException e){
System.out.println("Error::File Did Not Close");
}
}
}
}
public class ReadWrite {
public static void main(String[] args) {
int c;
InputStream istream;
OutputStream ostream;
istream =System.in;
ostream = System.out;
System.out.println("Anything Type");
try{
while((c=istream.read()) !=-1 )
ostream.write(c);
}catch(IOException e){
System.out.println("Error::"+e.getMessage());
}finally {
try{
istream.close();
ostream.close();
}catch(IOException e){
System.out.println("Error::File Did Not Close");
}
}
}
}
Comments
Post a Comment