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... ;)
Terms of Agreement:
By using this article, you agree to the following terms...
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.
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.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
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.
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:
Re-scan downloaded files using your personal virus checker before using it.
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...
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.
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.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
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( (If this comment was disrespectful, please report it.)
(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. (If this comment was disrespectful, please report it.)
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..
(If this comment was disrespectful, please report it.)
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!! (If this comment was disrespectful, please report it.)
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 (If this comment was disrespectful, please report it.)
4/8/2003 6:33:16 AM:
how can i display per line? (If this comment was disrespectful, please report it.)
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). (If this comment was disrespectful, please report it.)
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 (If this comment was disrespectful, please report it.)
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. (If this comment was disrespectful, please report it.)
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! (If this comment was disrespectful, please report it.)
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!!! (If this comment was disrespectful, please report it.)
4/29/2003 1:15:58 PM:
i believe what i download will help with my project (If this comment was disrespectful, please report it.)
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 (If this comment was disrespectful, please report it.)
11/23/2003 5:39:03 PM:
This is something special m8. gw. (If this comment was disrespectful, please report it.)
5/24/2005 6:09:56 AM:
This tutorial Helped me. This artical given me a nice example in various string handling program (If this comment was disrespectful, please report it.)
5/24/2005 6:13:12 AM:
very nice i was happy to download to this artical. it is very simple and very useful (If this comment was disrespectful, please report it.)
u provide all string related programs but i want string programs of input is-abc_def_mno. output -:mno_def_abc . i want programs this any langauge. if any body know ple send the program this mail id:b.muralykrishna@gmail.com.
thank you (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)