This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ebcdic to ascii Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ebcdic to ascii" Watch "ebcdic to ascii" New topic
Author

ebcdic to ascii

ryan wayne
Greenhorn

Joined: Aug 13, 2004
Posts: 9
hello all,

I am receiving a message from an as400 to win box so the message is in ebcdic
I have scoured forever for help and stumbles across this little ditty.
I would like to get an array of bytes and use this but
it is confusing to say the least. can some one show me an example of how this would be used?

thanks alot!

Dun Dagda
Ranch Hand

Joined: Oct 12, 2004
Posts: 54
Perhaps something like:

assuming the above code is in a proper class that has access to your Translate class, something like the above should work. You will then have a string of EBCDIC characters that you can use.

If I have misunderstood what you wanted, or written something stupid, please let me know.

DD


SCJP 1.4<br />SCWCD (in progress)
Dun Dagda
Ranch Hand

Joined: Oct 12, 2004
Posts: 54
Oops, your method returns an int, I forgot to cast it to a byte before putting it in the array like this:


Sorry about that, :roll:
DD
Dun Dagda
Ranch Hand

Joined: Oct 12, 2004
Posts: 54
Anyway, looking more closely at the constructors of the String class in the Java API documentation, String has overloaded constructors that handle byte arrays in a specified charset, so it should be possible to do something like this:

to give you a string translated into EBCDIC, rather than use the Translate class that you found.

DD
 
Consider Paul's rocket mass heater.
 
subject: ebcdic to ascii
 
Similar Threads
Packed decimal conversion - Java
initialization of final instance fields
Static variables
Why primitive arguement's value won't be changed even it's changed in method
ebcdic to ascii