Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

data extraction, and analysis of text files

Thread view: 
mambenanje@gmail.com - 26 Jun 2006 10:37 GMT
plz I have a project to read text files and extract data and perform
analysis, so I dont know if ther is any java library readily available
or any techniques or advice or website plz help me
Bart Cremers - 26 Jun 2006 10:43 GMT
mambenanje@gmail.com schreef:

> plz I have a project to read text files and extract data and perform
> analysis, so I dont know if ther is any java library readily available
> or any techniques or advice or website plz help me

It depends a bit on the format of the text file, but a general approach
would be to read the file using a BufferedReader wrapped around a
FileReader:

 BufferedReader reader = new BufferedReader(new
FileReader("inputfile.txt"));

The BufferedReader allows reading the file one line at a time. If no
more lines are available, the readLine() method simply returns 'null':

 for (String line = reader.readLine(); line != null; line =
reader.readLine()) {
     // Process line
 }

To process the line you'll need to use the various available classes
for String manipulation available in Java:

 String.split(), String.substring() or StringTokenizer to split the
line in processable parts.
 The parse methods in the Number classes to convert number to a
primitive (Integer.parseInt(), ...)
 ...

Regards,

Bart
mambenanje@gmail.com - 03 Jul 2006 11:26 GMT
well I think I understand your approach yeah when I read the file I
will use java.util.regex to go through it thanks very much
mambenanje@gmail.com - 03 Jul 2006 11:27 GMT
well I think I understand your approach yeah when I read the file I
will use java.util.regex to go through it thanks very much
Carlos Eduardo Lima Borges - 03 Jul 2006 18:39 GMT
I am parsing data from a GPS device.
The data comes separated by commas, it follows the NMEA protocol.
What I want to know is how to parse those strings using *as less memory
as possible*, since I am on the mobile environment, using Java ME (not
Java 5.0 then).

Thanks in advance!
mambenanje@gmail.com - 06 Jul 2006 10:20 GMT
well I think using the String.split approach will do the job for u and
it create only one array and returns you a reference and such no memory
waste
Carlos Eduardo Lima Borges - 07 Jul 2006 04:54 GMT
Thanks a lot!

Do you know anyway so that I can check the number of elements created?
It can be either directly, knowing the number of created objects in
memory or indirectly analyzing the size of each element and comparing
to the amount of free memory changed.
I don´t know how either of those approaches can be done nor do I know
any other approaches.
Any help appreciatted

> well I think using the String.split approach will do the job for u and
> it create only one array and returns you a reference and such no memory
> waste


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.