Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like Seva suggested you can split up your file in chunks. I used this to split up my 4MB file</p> <pre><code>public static void main(String[] args) throws Exception { String base = "tracks"; String ext = ".dat"; int split = 1024 * 1024; byte[] buf = new byte[1024]; int chunkNo = 1; File inFile = new File(base + ext); FileInputStream fis = new FileInputStream(inFile); while (true) { FileOutputStream fos = new FileOutputStream(new File(base + chunkNo + ext)); for (int i = 0; i &lt; split / buf.length; i++) { int read = fis.read(buf); fos.write(buf, 0, read); if (read &lt; buf.length) { fis.close(); fos.close(); return; } } fos.close(); chunkNo++; } } </code></pre> <p>If you do not need to combine the files into a single file on the device again, just use this InputStream, which combines them into one on the fly.</p> <pre><code>import java.io.IOException; import java.io.InputStream; import android.content.res.AssetManager; public class SplitFileInputStream extends InputStream { private String baseName; private String ext; private AssetManager am; private int numberOfChunks; private int currentChunk = 1; private InputStream currentIs = null; public SplitFileInputStream(String baseName, String ext, int numberOfChunks, AssetManager am) throws IOException { this.baseName = baseName; this.am = am; this.numberOfChunks = numberOfChunks; this.ext = ext; currentIs = am.open(baseName + currentChunk + ext, AssetManager.ACCESS_STREAMING); } @Override public int read() throws IOException { int read = currentIs.read(); if (read == -1 &amp;&amp; currentChunk &lt; numberOfChunks) { currentIs.close(); currentIs = am.open(baseName + ++currentChunk + ext, AssetManager.ACCESS_STREAMING); return read(); } return read; } @Override public int available() throws IOException { return currentIs.available(); } @Override public void close() throws IOException { currentIs.close(); } @Override public void mark(int readlimit) { throw new UnsupportedOperationException(); } @Override public boolean markSupported() { return false; } @Override public int read(byte[] b, int offset, int length) throws IOException { int read = currentIs.read(b, offset, length); if (read &lt; length &amp;&amp; currentChunk &lt; numberOfChunks) { currentIs.close(); currentIs = am.open(baseName + ++currentChunk + ext, AssetManager.ACCESS_STREAMING); read += read(b, offset + read, length - read); } return read; } @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); } @Override public synchronized void reset() throws IOException { if (currentChunk == 1) { currentIs.reset(); } else { currentIs.close(); currentIs = am.open(baseName + currentChunk + ext, AssetManager.ACCESS_STREAMING); currentChunk = 1; } } @Override public long skip(long n) throws IOException { long skipped = currentIs.skip(n); if (skipped &lt; n &amp;&amp; currentChunk &lt; numberOfChunks) { currentIs.close(); currentIs = am.open(baseName + ++currentChunk + ext, AssetManager.ACCESS_STREAMING); skipped += skip(n - skipped); } return skipped; } } </code></pre> <p>Usage:<br> <code>ObjectInputStream ois = new ObjectInputStream(new SplitFileInputStream("mytempfile", ".dat", 4, getAssets()));</code></p>
    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. 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