Revision as of 05:41, 30 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to read a binary file from JAR

From Nokia Developer Wiki
Jump to: navigation, search

If you want to read a binary file from JAR file (read only), for example a game level, a map, or any data information you have to:

  • Include the data file in to your project, so the IDE can append it to the JAR package.
  • Use the following code to read a binary file from the JAR
private byte[] readBinaryFile(String fileName) throws IOException {
InputStream input = getClass().getResourceAsStream(fileName);
ByteArrayOutputStream output = new ByteArrayOutputStream();
for (int read = input.read(); read >= 0; read = input.read())
byte[] buffer = output.toByteArray();
input.close ();
return buffer;
Article Metadata
Tested with
Devices(s): Nokia 7373, Nokia N82
Created: firt (15 Apr 2007)
Updated: tiviinik (17 Jan 2012)
Last edited: hamishwillee (30 Jul 2013)
This page was last modified on 30 July 2013, at 05:41.
77 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.