aspose file tools
The moose likes Java in General and the fly likes Reading binary from a file and converting to CHAR Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Reading binary from a file and converting to CHAR" Watch "Reading binary from a file and converting to CHAR" New topic
Author

Reading binary from a file and converting to CHAR

John Gable
Greenhorn

Joined: Apr 12, 2004
Posts: 11
Hi,

I'm trying to read binary from a text file into java - I want to read 8 bits and then convert that to a CHAR.

This is my code:



The problem I have is it's reading in as a number.
This is my output:

going to decrypt
value of answer b4 parsing: 0
value of answer: 17
inside decrypt for printb
this is the output: ◄
value of answer b4 parsing: 17
value of answer: 14
inside decrypt for printb
this is the output: ♫


basically I want value of answer b4 parsing to be : 00001111 (as a string)
value of answer: 00001111 (but as a int not a string)
because i pipe that into a decryption algoritm that takes the 8 bits and decrypts then i can convert back to char.

Any help would be much appreciated.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
I don't see where answer is defined.
John Gable
Greenhorn

Joined: Apr 12, 2004
Posts: 11
Answer is defined at the beginning of the method.

int answer = 0;
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Reading binary from a file and converting to CHAR
 
Similar Threads
Image Processing
Number format exception
Encrypt / Decrypt 10 digit Number
Converting String to Integer without losing leading zero's
Binary String to Hexadecimal value problem