Solved

Can Java applet read & write binary files

Posted on 1998-12-04
9
407 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
For an applet, use getResourceAsStream with url as parameter. For writing binary files from applets, you need to sign the applets
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

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

Expert Comment

by:evijay
Comment Utility
0
 

Author Comment

by:oualide
Comment Utility
0
 
LVL 8

Expert Comment

by:diakov
Comment Utility
0
 

Author Comment

by:oualide
Comment Utility
thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 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

12 Experts available now in Live!

Get 1:1 Help Now