I'm trying to read a file via http. (http://www-lehre.inf.uos.de/
~mmenning/balingen.ts). I wrote a Connector Class:
Using java Syntax Highlighting
- package gip.android.ogl;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URL;
- import android.util.Log;
- public class DataConnectorTS {
- private final String DEBUG_TAG = "DataConnectorTS";
- public DataConnectorTS() {}
- public void requestTS(String address) {
- try {
- URL url = new URL(address);
- Log.d(DEBUG_TAG, "url: " + url);
- Log.d(DEBUG_TAG,"host: "+url.getHost());
- readData(url.openStream());
- } catch (IOException e) {
- Log.e(DEBUG_TAG, "JML request IOError", e);
- }
- }
- private void readData(InputStream in){
- }
- }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
But by trying to connect in the ActivityClass
DataConnectorTS dcts= new DataConnectorTS();
dcts.requestTS("http://www-lehre.inf.uos.de/~mmenning/
balingen.jml");
I will only get the following ExceptionTrace:
01-27 17:00:18.605: ERROR/DataConnectorTS(182): JML request IOError
01-27 17:00:18.605: ERROR/DataConnectorTS(182):
java.net.UnknownHostException: Host is unresolved: www-
lehre.inf.uos.de:80
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
java.net.Socket.connect(Socket.java:928)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>
(HttpConnection.java:61)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager
$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection
(HttpConnectionManager.java:67)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection
(HttpURLConnection.java:800)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect
(HttpURLConnection.java:786)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream
(HttpURLConnection.java:1030)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
java.net.URL.openStream(URL.java:664)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
gip.android.ogl.DataConnectorTS.requestTS(DataConnectorTS.java:35)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
gip.android.ogl.FirstOGLApp.onCreate(FirstOGLApp.java:14)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1122)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2103)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2156)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.os.Handler.dispatchMessage(Handler.java:88)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.os.Looper.loop(Looper.java:123)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
android.app.ActivityThread.main(ActivityThread.java:3742)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
java.lang.reflect.Method.invokeNative(Native Method)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
java.lang.reflect.Method.invoke(Method.java:515)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
01-27 17:00:18.605: ERROR/DataConnectorTS(182): at
dalvik.system.NativeStart.main(Native Method)
I already added the uses-permission INTERNET Tag to the manifest.xml
(above the application tag).
I can create the URL Instance but not call openStream().
I also tryed to get the Stream via a HTMLConnection and so on, nothing worked and without Android, this class works as expected....
Any Idea what the problem could be?
Thanks for any help
Mathias

