Quick Search for:  in language:    
tutorial,will,teach,read,write,files,line,als
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Java/ Javascript Stats

 Code: 220,465. lines
 Jobs: 89. postings

 How to support the site

 
Sponsored by:

 
You are in:
 

Does your code think in ink?
Login





Latest Code Ticker for Java/ Javascript.
Gobang
By Geniusbob Xu Qiang on 11/27


Click here to see a screenshot of this code!Salary
By Vikram Ivatury on 11/25

(Screen Shot)

Click here to see a screenshot of this code!A (part10) Powerful Swing Code to Maintain CD Database
By James Smith K on 11/25

(Screen Shot)

String Calculator
By MadokaCoder on 11/24


Chobi Dekha
By ShuvoRim on 11/23


Click here to see a screenshot of this code!A basic Client Server application II
By Ronald Holland on 11/23

(Screen Shot)

Bookmark image
By darren kurn on 11/22


myFT
By Owolabi Oyapero on 11/22


Click here to see a screenshot of this code!Simple Socket example
By Steven McElrea on 11/20

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

File Handling and String Manipulation Tutorial

Print
Email
 

Submitted on: 4/1/2003 6:03:38 PM
By: Šonny Nadolny 
Level: Beginner
User Rating: By 13 Users
Compatibility:Java (JDK 1.1), Java (JDK 1.2)

Users have accessed this article 14454 times.
 
(About the author)
 
     This tutorial will teach you how to read and write files line by line. It also has the code to many string manipulations such as getting the middle of a string, searching/replacing text, and much more, even how to reverse a string! It also has fully working code to demostrate EVERYTHING! Note: Honest comments and generous votes are appreciated... ;)

This article has accompanying files
 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
The tutorial and code examples are in the zip files.

winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.


Other 3 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
4/6/2003 8:24:39 AM:
hi! i need some help? i have an asssignment wherein a program will read a file then display the number of characters, words and lines of that file. then it will prompt the user to enter example: input: L1<enter>. it will display line1 of that file. input: W3<enter>. it will display word3 of the file so on and so forth.. i know your very good in java and i am just a beginner.i hope that you could help me thank you very much
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/6/2003 3:43:24 PM:Šonny Nadolny
Hey. The code to read a file will work fine here, it reads it line by line. Just do a loop to get the input, if it begins with L (if (input.subString(0,1)).compareTo(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/6/2003 3:44:16 PM:Šonny Nadolny
Sorry, comment got cut off... (if (input.subString(0,1)).compareTo("L")) then you get the second character and get that line. For the words, split up the lines into words by splitting them based on the space characer (I have an example of that in the tutorial). If you need any more help, just post anotehr comment.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/6/2003 6:10:41 PM:
hello, The article was worth downloading..but i have a problem where i need to backup some files and directories at a specific time,though i can use the schedule() function of file class,i am not able to properly copy directories and files.i would be very happy to get some help in this issue..
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/6/2003 6:14:51 PM:
hi, The tutorial is worth downloading..but i have a problem where i need to back up some files & directories after a specified delay..i am able to schecule it with the schedule function of the timer class but i have problems copying files and directories properly..plz help me!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/6/2003 6:17:29 PM:Šonny Nadolny
Hey. I'm not sure how to copy entire directories... maybe a vote would help ;) You could try searching on google for: copy directory java and see what comes up. Sorry I can't help
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/8/2003 6:33:16 AM:
how can i display per line?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/8/2003 6:50:12 PM:Šonny Nadolny
The tutorial has a code example to read a file and print it out line by line (it reads it into an array first, although you could easily configure it to do whatever you want).
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/12/2003 3:26:18 AM:
Hi i want to calculate the no of called clases from a .java file. How can i do this can u help me
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/12/2003 3:29:28 AM:
Hi i need your help to count the out of package classes which are called from a .java file. Plz help me how can i do this.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/12/2003 9:02:40 AM:Šonny Nadolny
You need to open the .java file and search for the text "import java." and that would be one package. About the number of classes called, if you want the number it times they're called then you would need to get their names. If you just want to know how many there are, it would be hard, you'd need to search the file for any text that's not in quotes and is not a java keyword. Don't forget to vote!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/23/2003 11:02:23 PM:
I'm new to java, just exploring how to do i/o stream. this tutorial really helped me alot. it's so simple and easy to understand. THANKS DONNY!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/29/2003 1:15:58 PM:
i believe what i download will help with my project
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/18/2003 11:34:59 PM:
Thanks you for sharing. Q1. I want to know how can read the record from a database table and then output them into a flat file format (in ASCII)? Q2. Also to display them in Grid format ? Hope you can help....Best Regards
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/23/2003 5:39:03 PM:
This is something special m8. gw.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Java/ Javascript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.