Convert string to bytearray

Hi

 

i have written below java code to convert to string to bytearray. i am not sure whether its converting properly or not . can you please help

 

package SendDocRequestToTesaQAT;
import java.util.*;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
public class SendDocRequestToTesaQATconvertEncryptedStringtoByteArray{
/****** START SET/GET METHOD, DO NOT MODIFY *****/
    protected String encryptedString = "";
    protected byte[] encrytptedByteArray = null;
    public String getencryptedString() {
        return encryptedString;
    }
    public void setencryptedString(String val) {
        encryptedString = val;
    }
    public byte[] getencrytptedByteArray() {
        return encrytptedByteArray;
    }
    public void setencrytptedByteArray(byte[] val) {
        encrytptedByteArray = val;
    }
/****** END SET/GET METHOD, DO NOT MODIFY *****/
    public SendDocRequestToTesaQATconvertEncryptedStringtoByteArray() {
    }
    public void invoke() throws Exception {
/* Available Variables: DO NOT MODIFY
    In  : String encryptedString
    Out : byte[] encrytptedByteArray
* Available Variables: DO NOT MODIFY *****/
ByteArrayOutputStream byteArrayOutPutStream = null;
ObjectOutputStream out = null; 
byteArrayOutPutStream = new ByteArrayOutputStream();
out = new ObjectOutputStream(byteArrayOutPutStream);
                                   out.writeObject(encryptedString);
 //                    out.flush();
                                        
                encrytptedByteArray= byteArrayOutPutStream.toByteArray();

                    

System.out.println("encrytptedByteArray*********&&&&&&&&&&&&&&&&&&&&&&&&&&&&" + encrytptedByteArray);  

}
}
 

1 Comment

What TIBCO product are you using?

See: How to Ask and Answer Questions in this community

Don Johnson - Nov 28, 2016 - 9:23am
+ Add a Comment
Login