Write a Java program that reads a file and displays the file on the screen with a line number before each line


Write a Java program that reads a file and displays the file on the screen with a line number before each line
 
                            Week – 4
 
b)Aim: To Write a Java program that reads a file and displays the file on the screen with a line number before each line.
Source Code:
 
import java.io.*;
class linenum
{
           public static void main(String[] args)throws IOException
           {
                  FileInputStream fil;
                  LineNumberInputStream line;
                  int i;
                  try
                  {
                  fil=new FileInputStream(args[0]);
                  line=new LineNumberInputStream(fil);
                  }
                  catch(FileNotFoundException e)
                  {
                  System.out.println(“No such file found”);
                  return;
                  }
                  do
                  {
                  i=line.read();
                  if(i==’n’)
                  {
                                                                                                                                            System.out.println();
                                                                                                                                                       System.out.print(line.getLineNumber()+” “);
                  }
           else
                  System.out.print((char)i);
                  }while(i!=-1);
                  fil.close();
                  line.close();
           }
}
 
Expected Output:
 
Demo.java
class Demo
1 {
2         public static void main(java Demo beta gamma delta)
3 {
4 int n = 1 ;
5 System.out.println(“The word is ” + args[ n ] );
6 }
7 }
8 ?

Write a Java program that reads a file and displays the file on the screen with a line number before each line

( java read file screen line number algorithm source code )

https://en.wikipedia.org/wiki/Command-line_interface

Have any Question or Comment?

60 comments on “Write a Java program that reads a file and displays the file on the screen with a line number before each line

Thank you for the report.
Best regards,
Boswell Zacho

Reply

tadalafil best price tadalafil cialis buy tadalafil

Reply

does generic viagra work generic viagra review viagra alternatives

Reply

phd online thesis database help with writing thesis

Reply

online casino free spins onlinecasino001.com best online casino bonus codes.
bank of america loans personal personalloans1.site barclays personal loans.
online casino canada real money onlinecasinonodeposit001.com online casino free.
citizens one personal loans review easy personal loans personal loans interest rates.

Reply

demystifying dissertation writing doctoral dissertation writing dissertation writing coach

Reply

research methodology thesis http://thesisbyl.com/ editing thesis

Reply

avant personal loans review https://personalloans02.com best bank for personal loans.
casino movie online free https://www.onlinecasinonodeposit002.com live online casino real money.

Reply

personal loans for credit score under 600 https://personalloans02.com interest rates for personal loans.
usa online casino no deposit bonus codes 2020 https://www.onlinecasinonodeposit002.com online no deposit casino usa.

Reply

compare personal loans https://www.personalloans02.com bankofamerica personal loans.
nj online casino no deposit https://www.onlinecasinonodeposit002.com online gambling casino.

Reply

personal loans for credit score under 600 personalloans02.com personal loans for people with poor credit.
play for real money online casino https://www.onlinecasinonodeposit002.com las vegas online casino real money.

Reply

personal loans for 630 credit score https://personalloans02.com pre approved personal loans.
best online casino south africa https://onlinecasinonodeposit002.com online casino free spins.

Reply

government personal loans https://www.personalloans02.com stated income personal loans.
online casino no deposit bonuses https://onlinecasinonodeposit002.com hollywood casino online real money.

Reply

personal loans with no origination fee https://personalloans02.com personal loans reviews.
online casino uk free bonus no deposit https://www.onlinecasinonodeposit002.com online casino reviews 1 site for best online casinos.

Reply

world finance loans personal https://www.personalloans02.com which best describes a way people can use personal loans?.
online casino slots onlinecasinonodeposit002.com best free online casino games.

Reply

530 credit score personal loans http://www.personalloans02.com small personal loans online.
888 casino play online http://www.onlinecasinonodeposit002.com play casino slots online for real money.

Reply

personal loans with low interest https://personalloans02.com current interest rates for personal loans.
online no deposit casino bonus codes http://www.onlinecasinonodeposit002.com casino slots online play.

Reply

personal loans to pay off debt https://www.personalloans02.com guaranteed high risk personal loans fast.
play real casino games online http://www.onlinecasinonodeposit002.com online casino no deposit bonus.

Reply

citizens one personal loans review personalloans02.com personal consolidation loans.
best online casino no deposit bonus https://onlinecasinonodeposit002.com new online casino no deposit.

Reply

santander personal loans https://www.personalloans02.com credit karma personal loans.
online casino with free signup bonus real money usa https://www.onlinecasinonodeposit002.com online casino free bonus no deposit no download.

Reply

monevo personal loans https://www.personalloans02.com which best describes a way people can use personal loans?.
online casino real money nz https://onlinecasinonodeposit002.com online casino game.

Reply

cloud based personal loans https://personalloans02.com which bank is best for personal loans.
online casino games for real money for free http://www.onlinecasinonodeposit002.com online casino no deposit bonus code.

Reply

are personal loans taxable https://www.personalloans02.com personal loans no credit check online.
best casino games online http://www.onlinecasinonodeposit002.com best online casino for roulette.

Reply

promissory notes for personal loans http://www.personalloans02.com small personal loans no credit.
play casino slots for free online http://www.onlinecasinonodeposit002.com usa casino online real money.

Reply

does usaa give personal loans with bad credit http://www.personalloans02.com low interest personal loans online.
real online casino https://www.onlinecasinonodeposit002.com online casino with free bonus without deposit.

Reply

personal loans reviews personalloans02.com citizens bank personal loans.
online casino no deposit bonus keep what you win usa https://www.onlinecasinonodeposit002.com casino play online.

Reply

[…] Write a Java program that reads a file and displays the file on the screen with a line number before… […]

[…] Write a Java program that reads a file and displays the file on the screen with a line number before… […]

[…] k=20; do { System.out.println(k); k++; } while(k!=60); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number before… Java program to make frequency count of vowels, consonants, special symbols, digits, words in a […]

[…] { System.out.println(“Hello World”); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number before… Java program to make frequency count of vowels, consonants, special symbols, digits, words in a […]

[…] } } } Output: Fibonacci series of 7 numbers: 0 1 1 2 3 5 8 Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number before… Java program to make frequency count of vowels, consonants, special symbols, digits, words in a […]

[…] {  System.out.println(“odd no are”+a[i]); } } } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number before… Java program to make frequency count of vowels, consonants, special symbols, digits, words in a […]

[…] System.out.println(“Area of rectangle:”+Rec); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number before… Java program to make frequency count of vowels, consonants, special symbols, digits, words in a […]

[…] Write a Java program that reads a file and displays the file on the screen with a line number before… […]

[…] c=a+b; System.out.println(“sum of c:”+c); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number before… Java program to make frequency count of vowels, consonants, special symbols, digits, words in a […]

buy generic viagra

online viagra

viagra from canada

viagra dosage 40 mg

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.