I'm currently doing an assignment and I have a byte array that I write onto a file. I want to be able to get the byte array back out of the file by doing the reverse of what I did but I don't think I'm getting the right value back.
This is the code to write to the text file
PrintWriter fw = new PrintWriter(new BufferedWriter(new FileWriter("tc.txt",true)));
KeyPair keyPair = generateKeyPair();
byte[] publicKey = keyPair.getPublic().getEncoded();
byte[] privateKey = keyPair.getPrivate().getEncoded();
fw.println(email +" " + publicKey + " " + privateKey); //adds the site into the text file whcih contains all the blacklisted sites
fw.flush();
And I try to get information back as a string and use .getBytes() to convert it back to a byte array like this
tempPublicKey = (blScanner.next()).getBytes();
It doesn't seem to be right, does something happen in-between that is wrong?