Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Can Java applet read & write binary files

Posted on 1998-12-04
9
414 Views
Last Modified: 2008-02-26
If java can read & write binary files, I need to see a small example of this please. Thanks
0
Comment
Question by:oualide
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 50 total points
ID: 1228837
Absolutely. The simplest form would be something like:

FileInputStream fi=new FileInputStream(name);
byte b[]=new byte[30];
fi.read(b,0,30);
fi.close();

There is a FileOutputStream which has a method to write byte arrays. If you need reading and writing simultaneously you can use the RandomAccessFile which has similar methods for read and write.

0
 
LVL 16

Expert Comment

by:imladris
ID: 1228838
Note: The read and write methods listed above will get the sequence of bytes (30 in the above example) in the file. Converting that information to primitive entities may require some work on your part. For instance, if you want to get integers out  of the file: how many bytes are used to represent them? Are they encoded in little-endian or big-endian order? Similar and more complicated questions can arise for floating point numbers.

0
 
LVL 4

Expert Comment

by:evijay
ID: 1228839
For an applet, use getResourceAsStream with url as parameter. For writing applets, you need to sign the applets
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 4

Expert Comment

by:evijay
ID: 1228840
For an applet, use getResourceAsStream with url as parameter. For writing binary files from applets, you need to sign the applets
0
 

Author Comment

by:oualide
ID: 1228841
How to sign an applet and wher to find info. about this please.
Thanks.
0
 
LVL 4

Expert Comment

by:evijay
ID: 1228842
0
 

Author Comment

by:oualide
ID: 1228843
0
 
LVL 8

Expert Comment

by:diakov
ID: 1228844
0
 

Author Comment

by:oualide
ID: 1228845
thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question