on 05-09-2013 10:46 AM
Hi Every One,
Could anyone suggest me how to convert the ASCII to Hexadecimal (using UDF /Java mapping).
Thanks in Advance.
Hi Sahithi,
Here is a sample of a java mapping I have done where I had to take the input stream and convert it to a hexadecimal string so it could be processed in a proxy:
private String digits = "0123456789ABCDEF";
// Initialize variables, objects for processing
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
int c, len;
byte[] bytes = new byte[4096];
StringBuffer sb = new StringBuffer();
// Convert input stream to string in hexadecimal notation
try {
while((len = in.read(bytes)) != -1)
{
for(int i = 0; i < len; i++)
{
c = bytes[i] & 0xff;
sb.append(digits.charAt(c >> 4));
sb.append(digits.charAt(c & 0xf));
}
}
}catch (IOException e) {
e.printStackTrace();
}
// Now write to output stream
try {
// Output file data in hexadecimal string
bw.write(sb.toString());
bw.close();
}catch (IOException ex) {
ex.printStackTrace();
}
I tried using the Java version of toHexString() but found that there was some kind of bug that resulted in a bad string output.
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.