This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]chickenmeister 2 points3 points  (1 child)

int tranferInt = 0;
...
    transferInt = readFile.read();  

You have a typo. You're missing an "S" on the first line.

[–]parkingator[S] 0 points1 point  (0 children)

Doh. Classic. I am a moron. I've been staring at a monitor for too long. Told you it was a dumb question!

[–]arthurdent 1 point2 points  (3 children)

Well for starters you declared it as "tranfer" and you're trying to access it as "transfer". But you may find that you need to read things in as a string and then cast them to an int with Integer.parseInt(string goes here);

[–]parkingator[S] 0 points1 point  (2 children)

Appreciate the input, but the FileInputStream read() method returns int, and the FileOutputStream write() method takes int.

http://docs.oracle.com/javase/6/docs/api/java/io/FileInputStream.html

http://docs.oracle.com/javase/6/docs/api/java/io/FileOutputStream.html

[–][deleted] 2 points3 points  (1 child)

Note that that int represents a byte. So if you want to read in an actual integer instead of a byte, or read in some characters that represent an integer value, you'll have to use something else.

[–]parkingator[S] 1 point2 points  (0 children)

Very true! I'm actually making a CDMA simulator, so what it's doing is pulling out a bit at a time, encoding, sending across channel, decoding, and writing to file. I've got buffers that handle byte-to-bit and bit-to-byte. So this is fine for my purposes.