SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...Maulik Borsaniya
 
[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output Stream[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output StreamGhadeer AlHasan
 
File handling in c language
File handling in c languageFile handling in c language
File handling in c languageHarish Gyanani
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3MOHIT TOMAR
 
Session 02 python basics
Session 02 python basicsSession 02 python basics
Session 02 python basicsbodaceacat
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++Shyam Gupta
 
Chapter 10 Library Function
Chapter 10 Library FunctionChapter 10 Library Function
Chapter 10 Library FunctionDeepak Singh
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CAshim Lamichhane
 
C language header files
C language header filesC language header files
C language header filesmarar hina
 
Read write program
Read write programRead write program
Read write programAMI AMITO
 

Mais procurados (20)

Heap
HeapHeap
Heap
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output Stream[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output Stream
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
File handling in c language
File handling in c languageFile handling in c language
File handling in c language
 
Namespace1
Namespace1Namespace1
Namespace1
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
 
Session 02 python basics
Session 02 python basicsSession 02 python basics
Session 02 python basics
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
Python - Lecture 9
Python - Lecture 9Python - Lecture 9
Python - Lecture 9
 
Day2
Day2Day2
Day2
 
Day3
Day3Day3
Day3
 
Python for loop
Python for loopPython for loop
Python for loop
 
Python course Day 1
Python course Day 1Python course Day 1
Python course Day 1
 
Chapter 10 Library Function
Chapter 10 Library FunctionChapter 10 Library Function
Chapter 10 Library Function
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
 
File in c
File in cFile in c
File in c
 
C language header files
C language header filesC language header files
C language header files
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Read write program
Read write programRead write program
Read write program
 

Semelhante a Java Week4(C) Notepad

Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
source code which create file and write into it
source code which create file and write into itsource code which create file and write into it
source code which create file and write into itmelakusisay507
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntuKhurshid Asghar
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfmanojmozy
 
9 character string & string library
9  character string & string library9  character string & string library
9 character string & string libraryMomenMostafa
 
Presention programming
Presention programmingPresention programming
Presention programmingsaleha iqbal
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Ganesh Samarthyam
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)teach4uin
 
Functional Thinking for Java Developers (presented in Javafest Bengaluru)
Functional Thinking for Java Developers (presented in Javafest Bengaluru)Functional Thinking for Java Developers (presented in Javafest Bengaluru)
Functional Thinking for Java Developers (presented in Javafest Bengaluru)KonfHubTechConferenc
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfpratyushraj61
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxlez31palka
 

Semelhante a Java Week4(C) Notepad (20)

Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Inheritance
InheritanceInheritance
Inheritance
 
Java Programming - 06 java file io
Java Programming - 06 java file ioJava Programming - 06 java file io
Java Programming - 06 java file io
 
source code which create file and write into it
source code which create file and write into itsource code which create file and write into it
source code which create file and write into it
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 
9 character string & string library
9  character string & string library9  character string & string library
9 character string & string library
 
Presention programming
Presention programmingPresention programming
Presention programming
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
Java practical
Java practicalJava practical
Java practical
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 
JDK 8
JDK 8JDK 8
JDK 8
 
Lab4
Lab4Lab4
Lab4
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
Functional Thinking for Java Developers (presented in Javafest Bengaluru)
Functional Thinking for Java Developers (presented in Javafest Bengaluru)Functional Thinking for Java Developers (presented in Javafest Bengaluru)
Functional Thinking for Java Developers (presented in Javafest Bengaluru)
 
Computer programming 2 Lesson 12
Computer programming 2  Lesson 12Computer programming 2  Lesson 12
Computer programming 2 Lesson 12
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdf
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docx
 

Mais de Chaitanya Rajkumar Limmala (16)

Java notes
Java notesJava notes
Java notes
 
Java Week9(B) Notepad
Java Week9(B)   NotepadJava Week9(B)   Notepad
Java Week9(B) Notepad
 
Java Week6(B) Notepad
Java Week6(B)   NotepadJava Week6(B)   Notepad
Java Week6(B) Notepad
 
Java Week4(B) Notepad
Java Week4(B)   NotepadJava Week4(B)   Notepad
Java Week4(B) Notepad
 
Java Week8(A) Notepad
Java Week8(A)   NotepadJava Week8(A)   Notepad
Java Week8(A) Notepad
 
Java Week3(A) Notepad
Java Week3(A)   NotepadJava Week3(A)   Notepad
Java Week3(A) Notepad
 
Java Week10 Notepad
Java Week10   NotepadJava Week10   Notepad
Java Week10 Notepad
 
Java Week9(A) Notepad
Java Week9(A)   NotepadJava Week9(A)   Notepad
Java Week9(A) Notepad
 
Java Week7 Notepad
Java Week7   NotepadJava Week7   Notepad
Java Week7 Notepad
 
Java Week6(A) Notepad
Java Week6(A)   NotepadJava Week6(A)   Notepad
Java Week6(A) Notepad
 
Java Week4(A) Notepad
Java Week4(A)   NotepadJava Week4(A)   Notepad
Java Week4(A) Notepad
 
Java Week1(B) Notepad
Java Week1(B)   NotepadJava Week1(B)   Notepad
Java Week1(B) Notepad
 
Java Week2(C) Notepad
Java Week2(C)   NotepadJava Week2(C)   Notepad
Java Week2(C) Notepad
 
Java Week2(B) Notepad
Java Week2(B)   NotepadJava Week2(B)   Notepad
Java Week2(B) Notepad
 
Java Week1(A) Notepad
Java Week1(A)   NotepadJava Week1(A)   Notepad
Java Week1(A) Notepad
 
Java Week2(A) Notepad
Java Week2(A)   NotepadJava Week2(A)   Notepad
Java Week2(A) Notepad
 

Último

Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 

Último (20)

Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 

Java Week4(C) Notepad

  • 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