Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-15-2004, 04:21 AM   #1
LQ Newbie
Registered: Apr 2004
Posts: 1

Rep: Reputation: 0
Read text files

hi!! i am trying to write a software with Java 2 which require me to get infomation from a txt file and do some computation..

Example of text file:
1 15427U 84123A 04105.28666882 .00000305 00000-0 17871-3 0 3273
2 15427 98.6074 164.8044 0015862 96.3400 263.9646 14.15133964997644
1 16969U 86073A 04105.42065265 -.00000080 00000-0 -14183-4 0 2124
2 16969 98.7544 104.3853 0011689 304.4644 55.5432 14.27188008913932

My software must be able to detect NOAA 10 and do computation with the values classified under NOAA 10..

FileReader file = new FileReader("Tles.txt");
BufferedReader buff = new BufferedReader(file);
boolean eof = false;
while (!eof)
String line = buff.readline();
if (line == null)
eof = true;
if( line == "NOAA 10")
perform calculation;
}catch (IOException e){
System.out.println("Error - -" +e.toString());

Old 04-15-2004, 10:07 AM   #2
Registered: Apr 2004
Location: Edinburgh
Posts: 78

Rep: Reputation: 15
This is a function I wrote a long time ago about ppm image reading (ie ascii images )

I use a CharArrayWriterGetbuf to get the data and a BufferManipulator

public void read() throws IOException {
int c;
int i; // colonne
int j; // ligne
int[] results;
int beforeDynamique = 0;
int[][] pixels;

ImageBNW_ppm image = this;

CharArrayWriterGetbuf data = new CharArrayWriterGetbuf();

There I read the file, ie I transfer to a Buffer

while ((c = != -1) {

I manipulate the buffer

BufferManipulator buf = new BufferManipulator(data.getBuf());

I get the header (entete in French ;-) )
ct_entete = buf.getCharData (0, '\n');

beforeDynamique = image.getDimension(buf);

results = buf.getIntData(beforeDynamique, '\n');


I read the pixels array

pixels = new int[super.getWidth()][super.getHeight()];

for (j=0; j<super.getHeight(); j++) {
for (i=0; i<super.getWidth(); i++) {
getData read depending up to the last character, \n in this example
results = buf.getIntData(results[1], '\n');
pixels[i][j] = results[0];

Junk stuff for my application

image.mc_pixels = new MatrixCalcul(pixels, super.getWidth(), super.getHeight());




I hope it was helpful. I don't remember exactrly everything but it might give you some idea and some classes to try. If you want further details, I could send you the classes to open an image for you to play with.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 11:42 AM
mozzla problems-can not read files online, can not read attachments sarajevo Linux - Software 1 09-20-2005 06:58 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 11:42 AM
Read in an Octal number from a text file using C++ pjordan Programming 2 11-18-2004 03:03 PM
need a perlscript to read from a text file and transfer files via ftp cccc Linux - Networking 2 02-21-2004 06:18 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration