dcsimg
Did anybody use Forte for java???I am trouble in a func "readline()".
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   lu_yong
Posted On:   Wednesday, December 19, 2001 11:54 PM

I am trouble in using readline func.Who can help me??? My code like this: //////////////////////////////////////////////////////// InetAddress addr=InetAddress.getLocalHost(); System.out.println("Prepare to new socket"); clientSocket=new Socket(addr,port); System.out.println("Past the init socket"); clientSocket.setSoTimeout(5000); in=new BufferedReader( new InputStreamReader( clientSocket.getInputStream())); out=new PrintWriter(clientSocket.getOutputStream(), true ); ///////////// //I read socket by this code: while(in.ready()){ info=info+in.readLine()+"    More>>

I am trouble in using readline func.Who can help me???

My code like this:

////////////////////////////////////////////////////////

InetAddress addr=InetAddress.getLocalHost();

System.out.println("Prepare to new socket");

clientSocket=new Socket(addr,port);

System.out.println("Past the init socket");

clientSocket.setSoTimeout(5000);

in=new BufferedReader(
new InputStreamReader(
clientSocket.getInputStream()));

out=new PrintWriter(clientSocket.getOutputStream(), true );

/////////////

//I read socket by this code:

while(in.ready()){

info=info+in.readLine()+"
";

}

/////////////////////////////////////////////////////////



There is not any problem when I use them in Forte for java 3. But every time I used it out of Forte the system told me that "Read time out". But I used in.ready() to test, the func in.ready() return "true". I use the other way to read.The code is below:



///////////////////////////////////////////////////////

String info;

char[] ch=new char[100];

in.read(ch);

info=new String(ch);

index=info.indexOf("
");

System.out.print("n is ");

System.out.println(index);

index=info.indexOf("
");

System.out.print("r is ");

System.out.println(index);

System.out.println(info);

/////////////////////////////////////////////////////////



By this way I found there are something in the buffer including the char '
' and '
'. But why the readline func give me the Timeout Exception out of Forte?????

   <<Less

Re: Did anybody use Forte for java???I am trouble in a func "readline()".

Posted By:   Krzysztof_Raciniewski  
Posted On:   Thursday, December 20, 2001 12:14 AM

There are problems with BufferedReader.readline(). See
Sun Bug Database
. There are problems with interpreting '/r' and '/n' characters. I think you have to rewrite the readline method to get work on all Java versions.
About | Sitemap | Contact