data extraction, and analysis of text files

M

mambenanje

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
 
B

Bart Cremers

(e-mail address removed) 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
 
M

mambenanje

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
 
M

mambenanje

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
 
C

Carlos Eduardo Lima Borges

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!
 
M

mambenanje

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
 
C

Carlos Eduardo Lima Borges

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top