reading from url.openstream() misses EOL in android

by Michael » Mon, 13 Apr 2009 12:04:31 GMT


Sponsored Links
 Hi group,

I have following code in a sun jdk 1.6 desktop application as well as
in an android app. In the desktop application the html code of the
website is read in line by line as expected, but in android the EOL is
somehow missed and several, sometimes all, lines are read in in one.
What strikes me is, why does android behave different to the standard
jdk for this code?

URL url = new URL(" http://www.spiegel.de/" ;); //just an example
System.out.println(url);
DataInputStream dis = new DataInputStream(new BufferedInputStream
(url.openStream()));
while ((s = dis.readLine()) != null){
System.out.println(s);
}

Thanks for any ideas,
Michael

--~--~---------~--~----~------------~-------~--~----~



reading from url.openstream() misses EOL in android

by Michael MÁúČnch » Mon, 13 Apr 2009 12:04:38 GMT


 Hi group,

I have following code in a sun jdk 1.6 desktop application as well as in an
android app. In the desktop application the html code of the website is read
in line by line as expected, but in android the EOL is somehow missed and
several, sometimes all, lines are read in in one.
What strikes me is, why does android behave different to the standard jdk
for this code?

URL url = new URL(" http://www.spiegel.de/" ;); //just an example
System.out.println(url);
DataInputStream dis = new DataInputStream(new
BufferedInputStream(url.openStream()));
while ((s = dis.readLine()) != null){
System.out.println(s);
}

Thanks for any ideas,
Michael

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Error with custom made popup marker

I have a made custom popup marker. There is a button on the popup that
shows up when you click on a marker on the map. Its function is to
open a new activity when the button is clicked. So in the onClick
function of the setOnClickListener() call, I created a new object of
the Activity class and used that to call the various methods that
needs to start the activity but I keep getting a
java.lang.NullPointerException thrown regarding the line that calls
the startActivityForResult() method. Not sure of the best way to go
about this. More lights will be much appreciated. I have pasted a
sample code below.

...
readmore.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {

            Intent intent = new Intent( context, ListIncidents.class);
            final Activity activity = new Activity();
            intent.putExtra("items", itemsBundle);
            activity.startActivityForResult(intent,VIEW_INCIDENT);
            activity.setResult( activity.RESULT_OK );
        }
} );

...

-- 

2. How to highlight the text in webview.

Hi All,

I have a webview, i am getting data from some url.

Here is the problem i want to select the text, I want to add that particular
URL as book mark in WebView. Then i want to send an e-mail of selected data
to someone.

Can some one help on this please.


Regards
-Srinivasa Reddy

-- 

3. Notification's VIBRATE is not enabled when a phone calling

4. Querying Contacts DB w/ multiple synced accounts

5. Hard keyboard - opening direction

6. Changing the height of a WebView on runtime

7. scrolling a list within headder and footer