Results 1 to 8 of 8
Thread: Converting ASCII format
- 02-17-2009, 05:18 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 25
- Rep Power
- 0
- 02-17-2009, 02:07 PM #2
String message = "";
byte[] abytearrray = { 1, 4, 6, 9, 1 };
for(byte element:abytearray) {
message += Byte.toString(element);
}
That should work.
-MK12Tell me if you want a cool Java logo avatar like mine and I'll make you one.
-
yes new String(byteArray) is quite suitable.
- 02-17-2009, 02:13 PM #4
Oh that works?
Ok that would go faster then. Do what Fubarable said.
-MK12Tell me if you want a cool Java logo avatar like mine and I'll make you one.
-
for instance:
Java Code:public static void main(String[] args) { byte[] hexArray = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x73, 0x65, 0x65, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x28, 0x62, 0x79, 0x74, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x29, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x2e }; System.out.println(new String(hexArray)); }
- 02-17-2009, 03:34 PM #6
Member
- Join Date
- Feb 2009
- Posts
- 25
- Rep Power
- 0
Thanks to Forbearable
Your test code is really creative. Thank you ;)
- 02-17-2009, 03:45 PM #7
Member
- Join Date
- Feb 2009
- Posts
- 25
- Rep Power
- 0
Correction
Sorry for typo Fubarable. Can I ask you why you use 0x before Ascii codes?
-
Similar Threads
-
how to convert one format to another format
By mahipal_reddy621 in forum New To JavaReplies: 1Last Post: 12-02-2008, 10:21 AM -
I need help with ascii characters
By Grandon in forum EclipseReplies: 17Last Post: 11-08-2008, 02:12 AM -
Ascii code.........
By Somitesh Chakraborty in forum New To JavaReplies: 6Last Post: 11-04-2008, 05:32 PM -
Converting to ASCII and vice-versa
By pheonix in forum New To JavaReplies: 2Last Post: 09-09-2008, 04:43 AM -
Getting ASCII codes of character
By gapper in forum New To JavaReplies: 1Last Post: 02-02-2008, 09:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks