Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you misunderstood what the <code>java.io.File</code> class really represents. It is just a representation of the file on your system, i.e. its name, its path etc.</p> <p>Did you even look at the Javadoc for the <code>java.io.File</code> class? Have a look <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html" rel="noreferrer">here</a> If you check the fields it has or the methods or constructor arguments, you immediately get the hint that all it is, is a representation of the URL/path.</p> <p>Oracle provides quite an extensive tutorial in their <a href="http://docs.oracle.com/javase/tutorial/essential/io/file.html" rel="noreferrer">Java File I/O tutorial</a>, with the latest NIO.2 functionality too.</p> <p>With NIO.2 you can read it in one line using <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#readAllBytes%28java.nio.file.Path%29" rel="noreferrer">java.nio.file.Files.readAllBytes()</a>.</p> <p>Similarly you can use <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#write%28java.nio.file.Path,%20byte%5B%5D,%20java.nio.file.OpenOption...%29" rel="noreferrer">java.nio.file.Files.write()</a> to write all bytes in your byte array.</p> <p><strong>UPDATE</strong></p> <p>Since the question is tagged Android, the more conventional way is to wrap the <code>FileInputStream</code> in a <code>BufferedInputStream</code> and then wrap that in a <code>ByteArrayInputStream</code>. That will allow you to read the contents in a <code>byte[]</code>. Similarly the counterparts to them exist for the <code>OutputStream</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. 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