Suppose i have a byte array need to be converted to a char array and send over the network. eg
char[] sometoken = String( myByteArray ).toCharArray();
myMethodToSendByteArrayUsingTCPSocket( sometoken );
myByteArray is ASN.1 encoding (is a kerberos TGT) . At the receiving end, I am using this code to write "sometoken" to a file.
try{
fileName = .....;
fs = new FileOutputStream(fileName) ;
fs.write( new String( sometoken ).getBytes() );
fs.flush();
fs.close();
}catch(IOException e){
e.printStackTrace();
}
May I ask, if I should use DataOutputStream to write to file for reliability? Also, I believe need to specify the ASN.1 encoding for getBytes(). Is it getBytes("ASN.1") ?
thanks.