answersLogoWhite

0


Best Answer

import java.io.*;

class Files

{

public static void main(String a[])throws IOException

{

int i,line=0,c=0,len;

char k;

boolean m;

File f=new File("info.txt");

FileInputStream f1=new FileInputStream("info.txt");

len=f1.available();

for(i=0;i<=len;i++)

{

k=(char)f1.read();

c++;

System.out.print(k);

if(k='/n')

{

line++;

System.out.println(+line);

}

}

System.out.print("number of characters="+c);

}

}

User Avatar

Wiki User

βˆ™ 12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Java program that reads a file and display the file on the screen with a line number before each line?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you get a Java program to display a backslash in output without it interpreting it as a program command?

Follow the backslash with another backslash: System.out.println("\\ " \"); will display \ " \ on the screen.


How do you write a program using the gotoxy statement and print function to display letters of the alphabet on the computer screen?

There is no gotoxy statement in C.


How can you make a splash screen in c or c plus plus?

Many people use a modified version of the program's About dialogue window as a splash screen, but you can also create a dedicated splash screen window that contains an image of the company logo along with some program information. The choice is yours but ultimately a splash screen is nothing more than a window that is shown while a program loads in the background. When the program has loaded, the splash screen is closed automatically. The simplest method of displaying your splash screen is to use a program loader function. Typically this will be your program's main function or a function called from your main function. The program loader first loads and displays the splash screen, then loads the rest of your program in the background before closing the splash screen window and finally showing the main window. Some splash screens display progress information during the load sequence, thus your program loader should send messages to the splash screen and give time to the system to allow messages to be processed. This will increase the time it takes to load your program, but if the load process is lengthy to begin with, it is better to give some indication of the progress.


Why wont your c plus plus program stay open?

If you are talking about the program executing, but the output screen being displayed for a flash and then disappearing, I suggest adding getch() or getchar() function at the end of your main function. This will make sure that the output screen waits for you to press a character before the program terminates.


What is ffmpeg?

It is a screen recorder like Joyoshare VidiKit - Screen Recorder that can help you record online music, video games. lectures and more.

Related questions

Write a program to display your name on computer screen?

Faisal


How do you get a Java program to display a backslash in output without it interpreting it as a program command?

Follow the backslash with another backslash: System.out.println("\\ " \"); will display \ " \ on the screen.


What is the number of pixels seen on a screen called?

Display resolution .


Screen resolution indicates the number of that the computer uses to display the letters numbers graphics and background you see on the screen.?

pixels


Screen resolution indicates the number of that the computer uses to display the letters numbers graphics and background you see on the screen?

pixels


Program codes in turbo c that will display border on the console screen using for loops?

There is not one that I know off but you could write it.


How do you write a program using the gotoxy statement and print function to display letters of the alphabet on the computer screen?

There is no gotoxy statement in C.


What does the ghostscript software do?

Ghostscript is a program which allows a computer to read an image in PDF and display the results on the screen so that they are readable. This program also allows it to be printed in the correct format.


What indicates the number of pixels that a computer uses to display the letters numbers and background on a screen?

pixels


How do you know the dimensions of a game from its size in pixels?

Every screen will be different. You can approximate for your particular computer by dividing the height of the screen in pixels (the second number in your display resolution) by the height of the screen in centimeters. The number you get will be "pixels per cm" for your screen.


Mbitr users can program a channel using the radio's keypad and display window how do you access the screen for programming a channel?

Hold ALT+Mode. Go down to program. Hit enter


A program requires that you change the screen size from 1024 x 728 x 800 x 600 where?

Don’t know