aspose file tools*
The moose likes Beginning Java and the fly likes How do I read and write a binary file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do I read and write a binary file?" Watch "How do I read and write a binary file?" New topic
Author

How do I read and write a binary file?

Jonathan Gu
Greenhorn

Joined: Apr 01, 2002
Posts: 6
I wish to read and write a binary file (.gif)
and I wonder how can i do it in Java application?
BTW, how can i read a text file "line by line"
and end by EOF?
Please give me a easy example.
Thanx a lot
A Java Beginner..
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Hi Jonathan
You can use the following function to read a file

For reading the text file line by line you can use the following function

Hope this will help
Cheers
Amin


Regards<br />Aminur
Raghavan Srinivasan
Greenhorn

Joined: Apr 01, 2002
Posts: 1
Here is a simple example for reading from a text file line by line.
Jonathan Gu
Greenhorn

Joined: Apr 01, 2002
Posts: 6
Thanx a lot..
but how can i write a byte array into a file?
Please give an example..
Thanx again
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Hi
To write a byte array in the file create an OutputStream and use the method
OutputStream .write(byte [] byteArray);
You can take help of following function

Cheers
Jonathan Gu
Greenhorn

Joined: Apr 01, 2002
Posts: 6
thank you so much..!!
if i have any achievement in Java
the credit really belongs to u guys..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I read and write a binary file?