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. "Home Sample" has arrived and I can't make it go away

> How do I remove/delete/uninstall what I've done?

Go in Menu > Settings > Applications > Manager Applications and uninstall it.


This does NOT uninstall applications. It's used only to delete
shortcuts from the desktop, nothing more.

-- 
Romain Guy
www.curious-creature.org

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

2. onStart argiment change

Hi,
I am attempting to get the following service to work, and running into
problems. Seemingly the onStart function has updated parameters. It is
now expecting the Intent and an integer. How do I get the intent to
pass in to the function?

thanks

package com.stevemacleod.prankapp;

import java.io.IOException;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Binder;
import android.media.MediaPlayer;

public class PrankService extends Service
{
        MediaPlayer player = null;
        String str;
         public IBinder onBind(Intent intent)
         {
                return null;
         }

        public void onStart(int startId, Bundle arguments)
        {
                super.onStart(startId, arguments);
                try
                {
                        player = MediaPlayer.create((Context)this, 
R.raw.groove_arm);
                        player.start();
                } catch (IOException e)
                {
                        System.out.print("Exception while starting audio");
                }
        }
        public void onDestroy()
        {
                super.onDestroy();
                player.stop();
        }

}

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

3. "Home Sample" has arrived and I can't make it go away

4. Button Resize Issue

5. Can not find .apk file when I add external .jar files

6. Integration with other applications

7. Notepadv3 Issue - NullPointerException in onSaveInstanceState()