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. Some coding errors from a novice

Hi, I'm a beginner android developer, and I've only been coding for a
few months. I'm testing some layouts in a project using eclipse, and
I'm following the guidelines from a textbook (beginning android 2.0)
and I'm getting some rather perplexing errors. The first error is in
my main.xml. my code is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<ImageView
android:id="@+id/icon"
android:padding="2dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ok"
/>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
/>
</LinearLayout>

everything seems to work other than this line under ImageView:
android:src="@drawable/ok"

I'm not entirely sure what this means, but the error says:
Error:No resource found that matches the given name (at 'src' with
value '@drawable/ok').

Seeing as I don't really understand what I'm supposed to be
referencing, so I don't know where to begin fixing it.

Secondly, I'm getting two similar errors concerning how to create
fields in R.Java.

My code for Layout_Testing.java (my main .java file) is as follows:

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Layout_Testing extends ListActivity {
        private TextView selection;
        private static final String[] items={"lorem", "ipsum", "dolor",
        "sit", "amet",
        "consectetuer", "adipiscing", "elit", "morbi", "vel",
        "ligula", "vitae", "arcu", "aliquet", "mollis",
        "etiam", "vel", "erat", "placerat", "ante",
        "porttitor", "sodales", "pellentesque", "augue", "purus"};
        @Override
        public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        setListAdapter(new ArrayAdapter<String>(this,
        R.layout.row, R.id.label,
        items));
        selection=(TextView)findViewById(R.id.selection);
        }
        public void onListItemClick(ListView parent, View v,
        int position, long id) {
        selection.setText(items[position]);
        }
        }

everything works up until I try to set the list adapter
(setListAdapter):

setListAdapter(new ArrayAdapter<String>(this,
        R.layout.row, R.id.label,
        items));
        selection=(TextView)findViewById(R.id.selection);
        }

The error I'm getting says that they can't be resolved, so I attempted
to create a new field in R.Java. But, seeing as R.Java is derived, I
can't edit it. It just reverts back to before my edits. I'm really
confused about this and I figured this was the place to go for help.
Thanks for reading this, and if you have any suggestions, please email
me or respond!

Thanks,
James

-- 

2. Nyoba LCD Density di wildfire

setelah set lcd density, browsing internet ada lag ngga bro?

mocha




> 

3. Paging bro Rizki Muhammad

4. Market tidak bisa download

5. Feature graphics image quality. o_O

6. Problem with UI Thread which hangs up

7. how to increase camera resolution??