read a line of input at a time in Java?
Submitted by: AdministratorThe standard input stream is represented by the InputStream object System.in. For reading a whole line at a time BufferedReader is chained to an InputStreamReader that in turn is chained to System.in. For example: This program read line from a file “students” and displays it on screen.
import java.io.*;
import java.util.*;
public class stud
{
public static void main (String args[ ]) throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(newFileInputStream(“students”)));
String s= “”;
while ((s= br.readLine())!=null) System.out.println(s);
}
catch (IOException e)
{
System.out.println(e);
}
}
Submitted by: Administrator
import java.io.*;
import java.util.*;
public class stud
{
public static void main (String args[ ]) throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(newFileInputStream(“students”)));
String s= “”;
while ((s= br.readLine())!=null) System.out.println(s);
}
catch (IOException e)
{
System.out.println(e);
}
}
Submitted by: Administrator
Read Online Java Technical Job Interview Questions And Answers
Top Java Technical Questions
☺ | Explain Difference between Tomcat and Weblogic server? |
☺ | Explain different Authentication Options available in Servets? |
☺ | How does the native language C or C++ understand data types in JAVA? |
☺ | What is a StringBuffer class and how does it differ from String Class? |
☺ | read a line of input at a time in Java? |
Top Java Programming Language Categories
☺ | Core Java Interview Questions. |
☺ | Hibernate Interview Questions. |
☺ | Advanced Java Interview Questions. |
☺ | IBM WebSphere Interview Questions. |
☺ | Spring Framework Interview Questions. |