Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-24-2009, 02:36 AM
Member
 
Join Date: Oct 2009
Posts: 15
Rep Power: 0
Valkyrie is on a distinguished road
Default Convert integers into ACSII characters.
Does Java have a variant of the fromCharCode() method that is found in JavaScript?

This is the what I want to accomplish in Java:

Code:
<script type="text/javascript">

document.write(String.fromCharCode(72, 69, 76, 76, 79));

</script>
This JavaScript changes each digit to a ASCII character according to the number. So, does Java have a similar method to convert digits into ASCII characters?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-24-2009, 02:42 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,496
Rep Power: 8
Fubarable is on a distinguished road
Default
try
Code:
    byte[] asciiBytes = {72, 69, 76, 76, 79};
    System.out.println(new String(asciiBytes));
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-24-2009, 03:06 AM
Member
 
Join Date: Oct 2009
Posts: 15
Rep Power: 0
Valkyrie is on a distinguished road
Default
Ok, thank you Fubarable for your help. One more question, how do add a variable in using byte[]?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-24-2009, 03:10 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,496
Rep Power: 8
Fubarable is on a distinguished road
Default
Originally Posted by Valkyrie View Post
Ok, thank you Fubarable for your help. One more question, how do add a variable in using byte[]?
What do you mean?
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-24-2009, 03:39 AM
Member
 
Join Date: Oct 2009
Posts: 15
Rep Power: 0
Valkyrie is on a distinguished road
Default
Like having variable var in byte[] = {var}, assuming that var is a number.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting 3 Integers Using If Else MSteinman New To Java 12 02-19-2010 01:52 PM
convert fullwidth characters into halfwidth automatically nimitha New To Java 4 09-07-2008 04:58 PM
Random Integers www.kwalski.com Java Applets 8 12-09-2007 06:49 PM
Convert some special characters stored in a MySql romina Database 1 08-07-2007 06:32 AM
Convert roman numerals to integers Felissa Advanced Java 2 07-02-2007 12:27 AM


All times are GMT +2. The time now is 10:11 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org