Solved

Can Java applet read & write binary files

Posted on 1998-12-04
9
411 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example issue 6 39
Way to decrease size of apk file 9 67
null output 3 25
String array comparison 4 33
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

772 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