Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
reading in a file in java
Name: tony Date: July 21, 2003 at 06:34:49 Pacific OS: xp pro CPU/Ram: 256
Comment:
Hi, is it possible in Java to read in a file such as a jpeg and store the binary data of the file within an int array (assuming it would just be lots of 1's and 0's). help would be appreciated :)
Name: Giuseppe Date: July 22, 2003 at 08:33:23 Pacific
Reply:
Yeah, you can do it.
Have a look at classes in java.io: InputStream and DataInputStream. They offer 'read' methods which reads data from disk and put it into byte arrays.
You can use these classes in a Java standalone program. You can't gereally use them in a untrusted applet.
Giuseppe
0
Response Number 2
Name: tony Date: July 23, 2003 at 14:32:58 Pacific
Reply:
thanks very much, i'll try that then :)
0
Response Number 3
Name: tony Date: July 24, 2003 at 07:41:59 Pacific
Reply:
i have tried using the datainput stream but have run into a little trouble,
The code i have returns an unsigned byte value where as i would prefer a sequence of 10101 etc. the code i have so far is below. Is there anyway to just get java to return a sequence of the binary values and store it within an array? or do i need to convert each number into an 8 digit binary number?
import java.io.*;
class Fileatemmpt { public static void main(String args[]) { if (args.length == 1) { try { FileInputStream fstream = new FileInputStream(args[0]); DataInputStream in = new DataInputStream(fstream);
Summary: can we write a program in java , which can move a file in the network one computer to another computer by specifying the ip address.. i doesn't need a server & client.... program, i need a only a pr...
Summary: I'm not too good at reading from a file either, but what is CurrentSize in your SaveToFile? The file may be so big that it takes a long time for C++ to read it all. Have you tried just reading one App...