wood burning stoves 2.0*
The moose likes Servlets and the fly likes Parse a text file and save to a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Parse a text file and save to a database" Watch "Parse a text file and save to a database" New topic

Parse a text file and save to a database

christine lorraine

Joined: Sep 03, 2001
Posts: 20
hi, i will be developing a module wherein i will need to parse texts from a text file.
i am just wondering which one is a better and more efficient way...
is it uploading the text file first in the server and then proceed with parsing or should i just read the text file, store it in a stringbuffer and then parse the string.
thanks. appreciate your comments on this.
James wu

Joined: Feb 20, 2001
Posts: 5
java.lang.String is actually a char array wrapper same as StringBuffer is. So both of your methods will be almost same.
To parse a text file (like huge server log file), if it possible, do not try to load the whole file into memory. That may crash the server. Most of the text file parser will just read one line, then parse one line.
Hope that will help.
I agree. Here's the link: http://aspose.com/file-tools
subject: Parse a text file and save to a database
Similar Threads
Reading a CSV file as same in Excel
XML parser with good performance
Differentiate between text and url
How to make sure a file is a valid text file.