-
how to write them into separate text files using java
I have a text file having the following content:
......
end
............
...........
...................
end
............................
.........
end
What I'm trying to do is to divide the content of the file into several pieces just by the keyword "end", and then write each piece into a separate text file. Could anybody teach me how to implement this. Thank you very much!
-
What have you tried so far?
-
Read the file line by line using a loop. Store each line to an array or an arraylist, have an if statment that checks if the current line contains the word "end" strLine.equals("end"), if it does then save the new file, and create a new file and continue with the loop until you reach the end of the loop. Does that make any sense.
-
mysql, communication link failure
Hi guys hope some one can help. Im trying to connect my java app with mysql database which is running on a remote server meaning a web hosting account. I recieve the following message communication link failure. Has any one faced this problem before. I thoug maybe that that hosting compnay may not allow remote connections due to security reasons. So i installed mysql on my networked and tried to accessed it within my network but i get the same message. Any ways to where Im going wrong?
-
use Scanner class - with "end" as the delimiter. Write each of the tokens to a file, in turn.
-
ohhhh, thats where my thread went. I though I made a new thread for my java question, seems like I didnt make a new thread after all. Sorry guys must have clicked the wrong button. You can use the split function too. If im correct the split function is ment to replace the token
-
Yes - as the API documentation says for StringTokenizer:
StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.
Take a look at the Scanner class - it is VERY useful for all streams and for Strings, with great flexibility in delimiters and the handling of primitive datatypes.
Similar Threads
-
By symbian_ravi in forum Java
Replies: 0
Last Post: 12-20-2005, 05:29 AM
-
By Hutty in forum ASP.NET
Replies: 0
Last Post: 09-27-2005, 04:11 PM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
Replies: 0
Last Post: 04-07-2005, 01:31 PM
-
Replies: 1
Last Post: 11-27-2001, 06:53 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks