Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can Java applet read & write binary files

Posted on 1998-12-04
9
Medium Priority
?
420 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
[X]
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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 200 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

715 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