Your SlideShare is downloading. ×
Java Week4(C)   Notepad
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Java Week4(C) Notepad

371

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
371
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. JAVA WEEK4(C) /* Week 4 : c) Write a Java program that displays the number of characters, lines and words in a text file. */ import java.io.*; import java.util.*; public class LabPro10 { public static void main(String args[]) { try { FileInputStream f=new FileInputStream("run"); LineNumberReader lr=new LineNumberReader(new InputStreamReader(f)); String data; StringTokenizer st; int words=0,chars=0; while((data=lr.readLine())!=null) { st=new StringTokenizer(data); words+=st.countTokens(); chars+=data.length(); } System.out.println("total words"+words); System.out.println("total chras"+chars); System.out.println("total lines"+lr.getLineNumber()); f.close(); } catch(Exception e) {System.out.println("err"+e);} } } Page 1

×