It seems that s[1] somehow misses the s1.equals("") comparison. The
thing to check is what and how many characters s[1] contains. Add
something like:
int nLength = s[1].length()
System.out.println("Length of s[1]: " + nLength);
for (int i = 0; i < nLength; i++)
Hi Matthias,
I changed that code and included the s1.equals("") and i found out
that it is working that blank line is send as a blank line and other lines
are read as a normal line.The output is shown below.
s[0]=this is a test file which can
s[1]=
s[2]=be deleted when not neede
No. From the Java documentation (java.io.DataInput, readLine()):
> If the character '\n' is encountered, it is discarded and reading
> ceases. If the character '\r' is encountered, it is discarded and, if the
>following byte converts to the character
> '\n', then that is discarded also
>Date: Thu, 08 Jul 1999 12:48:49 +0200
>From: Matthias Pfisterer <[EMAIL PROTECTED]>
>
>Hi,
>
>In your java program, exchange the line
> if (s1.charAt(0)!='#') { // not a comment or NULL line
>with
> if (s1.equals("") || s1.charAt(0)!='#') { // not a comment or NULL line
or it could
Hi,
In your java program, exchange the line
if (s1.charAt(0)!='#') { // not a comment or NULL line
with
if (s1.equals("") || s1.charAt(0)!='#') { // not a comment or NULL line
Explanation:
You get empty lines as empty strings from readLine(). So you first have
to check whether th
Hi,
The code in JAVA is as following:
import java.lang.* ;
import java.io.* ;
public class PolicyServer { //: main class
public static void main (String [] args ) {
byte buf[]= new byte[64];
Please show us the code you used. That would make it much easier to
understand your problem and to help you.
Matthias Pfisterer
Chien-Lung Wu wrote:
>
> Hi,
> I try to read in a text file like follow,
>
> # comments
> #
> line1 with information
> line2 (blank)
> line3 with information
> line4
Hi,
I try to read in a text file like follow,
# comments
#
line1 with information
line2 (blank)
line3 with information
line4 (blank)
# comments
#comments
I write my program in C and also try to use JAVA. One thing very
interesting is my program can read-in this text file line by line (ether
i