terminated when executing to connection.getInputStream()?


#1

public byte[] getUrlBytes(String urlSpec) throws IOException{
URL url=new URL(urlSpec);
HttpURLConnection connection=(HttpURLConnection)url.openConnection();

    try{
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        Log.i(TAG,"开始执行: getInputStream()...");
        InputStream in=null;
        try {
             in = connection.getInputStream();
             Log.i(TAG, "getInputStream 已经调用.");
        }catch (IOException ex)
        {
            Log.i(TAG,ex.getMessage());
        }

        Log.i(TAG,"End getInputStream().");

        if(connection.getResponseCode()!=HttpURLConnection.HTTP_OK){
            throw new IOException(connection.getResponseMessage()+": with "+urlSpec);
        }

        int bytesRead=0;
        byte[] buffer=new byte[1024];
        while ((bytesRead=in.read(buffer))>0){
            out.write(buffer,0,bytesRead);
        }
        out.close();
        return out.toByteArray();
    }finally {
        connection.disconnect();
    }
}

01-07 12:04:37.395 8441-8441/? I/art: Not late-enabling -Xcheck:jni (already on)
01-07 12:04:37.396 8441-8441/? W/art: Unexpected CPU variant for X86 using defaults: x86_64
01-07 12:04:37.960 8441-8441/com.bignerdranch.android.phonegallery W/System: ClassLoader referenced unknown path: /data/app/com.bignerdranch.android.phonegallery-1/lib/x86_64
01-07 12:04:38.008 8441-8441/com.bignerdranch.android.phonegallery I/InstantRun: starting instant run server: is main process
01-07 12:04:38.318 8441-8441/com.bignerdranch.android.phonegallery W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
01-07 12:04:38.596 8441-8458/com.bignerdranch.android.phonegallery I/FlickrFetchr: url:https://api.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=4b096054791f66ac2b6889b348019229&format=json&nojsoncallback=1&extras=url_s&per_page=3
01-07 12:04:38.608 8441-8458/com.bignerdranch.android.phonegallery D/NetworkSecurityConfig: No Network Security Config specified, using platform default
01-07 12:04:38.608 8441-8458/com.bignerdranch.android.phonegallery I/FlickrFetchr: 开始执行: getInputStream()…
01-07 12:04:38.741 8441-8460/com.bignerdranch.android.phonegallery I/OpenGLRenderer: Initialized EGL, version 1.4
01-07 12:04:38.741 8441-8460/com.bignerdranch.android.phonegallery D/OpenGLRenderer: Swap behavior 1
01-07 12:04:38.741 8441-8460/com.bignerdranch.android.phonegallery W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without…
01-07 12:04:38.741 8441-8460/com.bignerdranch.android.phonegallery D/OpenGLRenderer: Swap behavior 0
01-07 12:04:38.776 8441-8460/com.bignerdranch.android.phonegallery D/EGL_emulation: eglCreateContext: 0x7482ada36aa0: maj 2 min 0 rcv 2
01-07 12:04:38.861 8441-8460/com.bignerdranch.android.phonegallery D/EGL_emulation: eglMakeCurrent: 0x7482ada36aa0: ver 2 0 (tinfo 0x7482ada0c580)
01-07 12:04:38.898 8441-8441/com.bignerdranch.android.phonegallery W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
01-07 12:04:38.906 8441-8460/com.bignerdranch.android.phonegallery D/EGL_emulation: eglMakeCurrent: 0x7482ada36aa0: ver 2 0 (tinfo 0x7482ada0c580)


#2

Hey @flying did you resolve this issue?