Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is <a href="http://github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/Network/DownloadFile.java#L50" rel="nofollow noreferrer">the class I use</a> to download a file from the internet or copy a file within the filesystem and how I use it:</p> <pre><code>// Download a file to /data/data/your.app/files new DownloadFile(ctxt, "http://yourfile", ctxt.openFileOutput("destinationfile.ext", Context.MODE_PRIVATE)); // Copy a file from raw resource to the files directory as above InputStream in = ctxt.getResources().openRawResource(R.raw.myfile); OutputStream out = ctxt.openFileOutput("filename.ext", Context.MODE_PRIVATE); final ReadableByteChannel ic = Channels.newChannel(in); final WritableByteChannel oc = Channels.newChannel(out); DownloadFile.fastChannelCopy(ic, oc); </code></pre> <p>There also is the Selector approach, here are some great (Java) tutorials about Selectors, Channels and Threads:</p> <ol> <li><a href="http://jfarcand.wordpress.com/2006/05/30/tricks-and-tips-with-nio-part-i-why-you-must-handle-op_write" rel="nofollow noreferrer">http://jfarcand.wordpress.com/2006/05/30/tricks-and-tips-with-nio-part-i-why-you-must-handle-op_write</a></li> <li><a href="http://jfarcand.wordpress.com/2006/07/06/tricks-and-tips-with-nio-part-ii-why-selectionkey-attach-is-evil/" rel="nofollow noreferrer">http://jfarcand.wordpress.com/2006/07/06/tricks-and-tips-with-nio-part-ii-why-selectionkey-attach-is-evil/</a></li> <li><a href="http://jfarcand.wordpress.com/2006/07/07/tricks-and-tips-with-nio-part-iii-to-thread-or-not-to-thread/" rel="nofollow noreferrer">http://jfarcand.wordpress.com/2006/07/07/tricks-and-tips-with-nio-part-iii-to-thread-or-not-to-thread/</a></li> <li><a href="http://jfarcand.wordpress.com/2006/07/19/httpweblogs-java-netblog20060719tricks-and-tips-nio-part-iv-meet-selectors/" rel="nofollow noreferrer">http://jfarcand.wordpress.com/2006/07/19/httpweblogs-java-netblog20060719tricks-and-tips-nio-part-iv-meet-selectors/</a></li> <li><a href="http://jfarcand.wordpress.com/2006/09/21/tricks-and-tips-with-nio-part-v-ssl-and-nio-friend-or-foe/" rel="nofollow noreferrer">http://jfarcand.wordpress.com/2006/09/21/tricks-and-tips-with-nio-part-v-ssl-and-nio-friend-or-foe/</a></li> </ol>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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