Only one line of output with DataInputStream.readLine() in android

by Michael » Mon, 13 Apr 2009 12:08:27 GMT


Sponsored Links
 Hi group,

I use the following code in a java-program on my desktop with sun-
jdk-1.6.0.13 to read a html file on my webserver. I get several lines
of output as expected. But when I use it in an android-app, the whole
html file is read in only one line.

Where could be the difference between the desktop and android
implementation? Do I have to change something like the encoding or
linebreak character?

URL url = new URL(" http://mysite.intern/test.html" ;);
System.out.println(url);
DataInputStream dis = new DataInputStream(new BufferedInputStream
(url.openStream()));
        while ((s = dis.readLine()) != null){
        System.out.println(s);
}

Thanks,
Michael

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



Other Threads

1. Clarification on loading local images with WebView



As I wrote in my previous reply:

Try creating a ContentProvider to serve the image, and see if you have
better luck with a content:// URL.


Not if your image is only in an asset. The image viewer won't have
rights to access it.


Not directly, but you can use the 2D graphics API (e.g., Canvas and
friends). Basically, you're looking to use the same techniques games do
to view a portion of a large map, for example.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Online Training: 21-25 June 2010: http://onlc.com

-- 

2. Clarification on loading local images with WebView

Hello all,
I apologize if this is beating a dead horse, but I have been through
the documentation and groups discussions over and over, and can't seem
to resolve this issue....

What I want to do:
- I am loading a remote web page into WebView using loadUrl() -
example:  webView.loadUrl("http://myserver.com/page.html");
- That page has a very large image in it whose quality I do not want
degraded by the OS. So I am putting it in the assets directory of the
app.
- The page.html that gets downloaded from my server, then has a
regular img tag in it like so:
<img src="file:///android_asset/largeimage.png"/>

I know there were some issues with reading assets from the file system
with different versions of the platform. But its not clear what
versions this affects and how to address the problem for all versions.
Can someone please clarify:

A) should what I am doing above work (because its not)

B) If it only works on some versions of the platform - which versions?
How should this be addressed when I can't guarantee what version of
the platform users are running?

I am targeting version 1.6 in my app because I thought that would be a
"safe" version to target. I am testing against version 2.0.1

Thanks,
Jeff

-- 

3. broken pipe over ssl

4. Internet data request done via ContentProvider?

5. About layout

6. how to test touchscreen drive

7. Animating Views with custom layout