Android Socket InputStream problem?

First of all System.out. Println(......) Doesn't work with android, you have to use the Log. *() to put your messages in the Log file and read it using DDMS Then I'm adding some code to read an InputStream just in case your having trouble (or anybody elase that willr ead this later on: BufferedReader buf = new BufferedReader(new InputStreamReader(con.getInputStream())); String thisLine = null; while ((thisLine = buf.readLine())!

= null) { Log. E(TAG,thisLine); } or read this In Java how do a read/convert an InputStream in to a string?

Thnak you for answering! In fact, I can see System.out. Println(...) on DDMS.My problem is not reading String or message, the problem is that the inputStream should not read data only once.....that is really strange!

It does not happen on desktop, but it happens on Android! – Wilhelm Chen May 29 at 9:52.

That's a wierd piece of code. You don't check the return value of read() for -1, i.e. EOS, and you only display the first byte of the data received and throw the rest away.

It works on Android, but the inputStream read only once, and then get stuck; If I want to read more data, I have to use outputStream to send some data, then inputStream will read once, and get stuck again. That is really strange, could anyone tell me why? There is no problem in System.out.print(), because DDMS can show it, I promise!

The problem is inputStream should not read only once, it should read when data comes. But it didn't , it read only once. Even if, I only print one byte from the buffer, it get stuck on Android.

It works very well on desktop, but get stuck on Android.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions