Java Week4(B)   Notepad
Upcoming SlideShare
Loading in...5
×
 

Java Week4(B) Notepad

on

  • 525 views

 

Statistics

Views

Total Views
525
Views on SlideShare
525
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Java Week4(B)   Notepad Java Week4(B) Notepad Document Transcript

  • JAVA WEEK4(B) /* Week 4 : b) Write a Java program that reads a file and displays the file on the screen, with a line number before each line. */ import java.io.*; import java.util.*; public class LabPro9 { public static void main(String args[]) { try { FileInputStream f=new FileInputStream("run"); LineNumberReader lr=new LineNumberReader(new InputStreamReader(f)); String data; while((data=lr.readLine())!=null) { System.out.println(lr.getLineNumber()+":"+data); } System.out.println("total lines"+lr.getLineNumber()); f.close(); } catch(Exception e) {System.out.println("err"+e);} } } Page 1