Solved

Can Java applet read & write binary files

Posted on 1998-12-04
9
408 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now