Java ashishfa. ? How to read file in Java How to read file in Java Developing application to expand abbreviation in given text Developing application.

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

LECTURE 17 C++ Strings 18. 2Strings Creating String Objects 18 C-string C++ - string \0 Array of chars that is null terminated (‘\0’). Object.
Lab1: File I/O and Streams Lecturer: Mauro Conti T.A.: Eyüp S. Canlar.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
School of Computing Science CMT1000 © Ed Currie Middlesex University Lecture 11: 1 CMT1000: Introduction to Programming Ed Currie Lecture 10: File Input.
James Tam Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java.
® Microsoft Office 2010 PowerPoint Tutorial 2: Adding and Modifying Text and Graphic Objects.
INTRODUCTION TO PYTHON PART 2 INPUT AND OUTPUT CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Hive UDF content/uploads/downloads/2013/09/HWX.Qu bole.Hive_.UDF_.Guide_.1.0.pdf UT Dallas 1.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Chapter 4 MATLAB Programming Combining Loops and Logic Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Two Ways to Store Data in a File Text format Binary format.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
THE BIG PICTURE. How does JavaScript interact with the browser?
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Software Writer:-Rashedul Hasan Editor:- Jasim Uddin.
Chapter 3: The UNIX Editors ASCII and vi Editors.
STRINGS & STRING HANDLING FUNCTIONS STRINGS & STRING HANDLING FUNCTIONS.
Dr. Yang, QingXiong (with slides borrowed from Dr. Yuen, Joe) LT8: Characters and Strings CS2311 Computer Programming.
Welcome to the Lecture Series on “Introduction to Programming With Java”
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington File handeling and Scanning.
Introduction to Computer Programming Using C Session 23 - Review.
Java Arrays …………. Java Arrays …………. * arrays are objects in Java * arrays are objects in Java * an array variable is a reference * an array variable is.
BUILDING JAVA PROGRAMS CHAPTER 7 Arrays. Exam #2: Chapters 1-6 Thursday Dec. 4th.
SE-1020 Dr. Mark L. Hornick 1 File Input and Output.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
Day 2 – Logic and Algorithms REACHING WIDER SUMMER SCHOOL.
1 STRINGS String data type Basic operations on strings String functions String procedures.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Java FilesOops - Mistake Java lingoSyntax
Strings. Our civilization has been built on them but we are moving towards to digital media Anyway, handling digital media is similar to.. A string is.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Awk Programming (3) Ruibin Bai (Room AB326) Division of Computer Science The University.
LING 408/508: Programming for Linguists Lecture 11 October 5 th.
1 CSC103: Introduction to Computer and Programming Lecture No 28.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
NMD202 Web Scripting Week2. Web site
Day 26 Arrays Episode 2. Array Lengths To determine the length of an array, use the command: array_Name.length.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington File handeling and Scanning.
Find text. 1 Find and replace text. 2 Find and replace special characters. 3 Find and replace formatting. 4 2.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
C++ Memory Management – Homework Exercises
Creates the file on disk and opens it for writing
Beginning of Class (On lined paper)
Lecture Note Set 1 Thursday 12-May-05
EEL 3705 / 3705L Digital Logic Design
Operation System Program 4
Imperative Programming
“Introduction to Programming With Java”
Command Line Arguments
Creates the file on disk and opens it for writing
Strings A string is a sequence of characters that is treated as a single value. Strings are objects. We have been using strings all along. Every time.
Strings.
LING 408/508: Computational Techniques for Linguists
Rocky K. C. Chang 30 October 2018 (Based on Zelle and Dierbach)
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Appending or adding to a file using python
Python 16 Mr. Husch.
Python 16 Mr. Husch.
Computer Applications -Generic Elective
Imperative Programming
Presentation transcript:

Java ashishfa

? How to read file in Java How to read file in Java Developing application to expand abbreviation in given text Developing application to expand abbreviation in given text –“Mr. Vasant and Mr. Gajanan went to IIT” –“Mister Vasant and Mister Gajanan went to Indian Institute of Technology”

Files for us Files can store text, formatted reports, pictures, songs, animations and programs Files can store text, formatted reports, pictures, songs, animations and programs Names of files Names of files –report.doc –Readme.txt –Flower.jpg Text files means files that contain text (no other symbols.) i.e. the files that can be read through Notepad or editplus or vi in unix.

Files for computers File has name in computer. File has name in computer. Java program cam read a file or write to a file or can modify the contents of file. Java program cam read a file or write to a file or can modify the contents of file. File is treated as a resource. File is treated as a resource. We need to open and close files while using them We need to open and close files while using them To use files To use files –It is assigned a name –It is then opened by open command –Then read /write commands are used –Then file is closed

FileReader fr = new FileReader("sample.txt"); BufferedReader bfr = new BufferedReader(fr); String str = bfr.readLine(); System.out.println("File contains"); while(str != null) { System.out.println(str); str = bfr.readLine(); } bfr.close();

Abbreviation expanding Logic Logic –Store abbreviations and corresponding expansions –Search them –Replace them –Repeat

data representation Ab.Expansion 0Mr.Mister 1Ms. Miss 2Dr. Doctor 3MA Master of arts

Find and replace “Hello! Mr. Vasant” “Hello! Mr. Vasant” Mr.Mr >>Hello! << 2.>>Hello! Mister<< 3.>>Hello! Mister Vasant<<

String functions used indexof(String) indexof(String) substring(a,b) substring(a,b) substring(a) substring(a) length() length() ab a end a

See the code Abbr.java

Abbreviation expansion using file Storing abbreviations in arrays in program is not convenient Storing abbreviations in arrays in program is not convenient Better way is to isolate data and program Better way is to isolate data and program –i.e. keep abbreviations in seperate file –Read the abbreviations from this file Modify abbreviation program Modify abbreviation program

Abbreviation file Mr.MisterDr.DoctorMA Master of arts... Odd line number Even line number 6 lines i.e. 3 entries 0 Mr.Mister 1 Dr.Doctor Single entry

exercise Write a program to search a text file and print only those lines which has the search word in it. Write a program to search a text file and print only those lines which has the search word in it. –Take i/p word from user –Open the text file –Read line by line from it –Search for i/p word in each line –Close file at the end

Thank You ;)