Article View: borland.public.jbuilder.java.language
Article #19282Am I too blind
From: TheCorp
Date: Tue, 24 Feb 1998 00:00
Date: Tue, 24 Feb 1998 00:00
58 lines
2160 bytes
2160 bytes
i'm trying to read blanks away from line that I read from file.
This program seems to loose some chars, don't know why?? Can enyone help
me I have been looking this code for two days and ... can figure out
what's the matter.
here's the code:
import java.io.*;
public class readWhite
{
public static void main(String args[]) throws IOException
{
RandomAccessFile rf = new RandomAccessFile(args[0],"r");
String line = null;
int i = 0;
int k = 0;
int len = 0;
line=rf.readLine();
line=rf.readLine(); //just reading lines away...
line=rf.readLine();
line=rf.readLine();
line=rf.readLine();
len = line.length();
char rivi[] = new char[len];
System.out.println(line); // just checking
for(i=0;i<len;i++)
{
if(line.charAt(i)!=' ') // &&
line.charAt(i)!='#')
{
rivi[k]=line.charAt(i);
k++;
}
}
String jop = new String(rivi);
jop.trim(); //cleans blanks from end and start
System.out.print(jop);
System.out.println();
for(i=0;i<len;i++)
{
System.out.print(rivi[i]);
}
}
}
and here's sample file:
######
##comments
##
######
( cs ""
(host "<string>")
(port "<int>")
)
##
Technical Details
Message-ID:
<34F2AA2B.5159@pcuf.fi>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,17a77f3ec24c635,start X-Google-Attributes: gidf74b3,public From: TheCorp <thecorp@pcuf.fi> Subject: Am I too blind Date: 1998/02/24 Message-ID: <34F2AA2B.5159@pcuf.fi> X-Deja-AN: 328135485 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: None Newsgroups: borland.public.jbuilder.java.language