Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to read file from server
    primarykey
    data
    text
    <p>I want to download file from server. File is created successfully in my android device but that file is empty file. it is not writing anything in file.</p> <p>My filereading code is as follows:</p> <pre><code>URL url = new URL(urlString); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.setDoOutput(true); //connect urlConnection.connect(); File SDCardRoot = Environment.getExternalStorageDirectory(); //create a new file, to save the downloaded file File file = new File(SDCardRoot,pos); FileOutputStream fileOutput = new FileOutputStream(file); //Stream used for reading the data from the internet InputStream inputStream = urlConnection.getInputStream(); //this is the total size of the file which we are downloading totalSize = urlConnection.getContentLength(); //create a buffer... byte[] buffer = new byte[1024]; int bufferLength = 0; while ( (bufferLength = inputStream.read(buffer)) &gt; 0 ) { fileOutput.write(buffer, 0, bufferLength); downloadedSize += bufferLength; } fileOutput.close(); } </code></pre> <p>I have debugged the code. There is something wrong in while ( (bufferLength = inputStream.read(buffer)) > 0 ) condition as the compiler didnt go inside this loop.</p> <p>My log cat error:</p> <pre><code>ERROR/ActivityThread(8218): Activity com.sec.android.app.myfiles.DetailsActivity has leaked IntentReceiver com.sec.android.app.myfiles.DetailsActivity$4@42760570 that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity com.sec.android.app.myfiles.DetailsActivity has leaked IntentReceiver com.sec.android.app.myfiles.DetailsActivity$4@42760570 that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.&lt;init&gt;(LoadedApk.java:792) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1254) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1241) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1235) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372) at com.sec.android.app.myfiles.DetailsActivity.setLocaleReceiver(DetailsActivity.java:185) at com.sec.android.app.myfiles.DetailsActivity.onCreate(DetailsActivity.java:121) at android.app.Activity.performCreate(Activity.java:5206) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125) at android.app.ActivityThread.access$600(ActivityThread.java:140) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4898) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload