Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

BufferedReader

Rahimv's picture

Create a program which prints number of lines in the file

0
Your rating: None
  1. /*
  2. Create a program which prints number of lines in the file. File name
  3. should be supplied using command line argument.
  4. */
  5.  
  6. import java.io.*;
  7. class CountNumberOfLinesFile
  8. {
  9.  public static void main(String args[])
  10.  {
  11.   try
  12.   {
  13.    FileReader fr = new FileReader(args[0]);
  14.    BufferedReader br = new BufferedReader(fr);
  15.    String line;
  16.    int count = 0;
  17.    
Rahimv's picture

Create a program which reads a line from console and prints number of characters

3
Your rating: None Average: 3 (1 vote)
  1. /*
  2.  * Create a program which reads line from console and prints number of characters. Program
  3.  * should read the line from keyboard. Use BufferedReader for reading the line from console.
  4.  */
  5.  
  6. import java.io.*;
  7.  
  8. class ReadFromKeyboard
  9. {
  10.  public static void main(String args[])
  11.  {
  12.   try
  13.   {
  14.    DataInputStream din = new DataInputStream(System.in);
Rahimv's picture

Create a program which reads file using readLine method of BufferedReader class

0
Your rating: None
  1. /*
  2. Create a program which reads file using readLine method of BufferedReader class. File name
  3. should be supplied using command line argument.
  4. */
  5.  
  6. import java.io.*;
  7. class BufferedReaderDemo
  8. {
  9.  public static void main(String args[])
  10.  {
  11.   try
  12.   {
  13.    FileReader fr = new FileReader(args[0]);
  14.    BufferedReader br = new BufferedReader(fr);
  15.    String line;
  16.    
Syndicate content