views:

46

answers:

2

the file abc.txt has several lines of ciphertext. i want to encode the line of ciphertext into hex encode or base64 before putting in string srr . is there any way i can do it ?

bufferedReader = new BufferedReader(new FileReader("abc.txt"));

                             String srr = null;

                             srr = bufferedReader.readLine()
+2  A: 

What kind of cipertext is stored in abc.txt? If it's binary, you shouldn't use a FileReader to read it, because FileReader is using some character encoding that could change your input bytes. Use a FileInputStream instead.

tangens
+2  A: 

If you want to encode it in Base64 then you can use Commons Codec:

http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html

or you can hex encode:

http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Hex.html

Jon