ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Converting String to int

Post new topic  Reply to topic
 Converting String to int « View previous topic :: View next topic » 
Author Message
chanchal
PostPosted: Thu Mar 25, 2004 7:16 am    Post subject: Converting String to int Reply with quote

Apprentice

Joined: 30 Jan 2004
Posts: 38

Can anybody tell me how to convert a String variable to int??
Back to top
View user's profile Send private message
EddieA
PostPosted: Thu Mar 25, 2004 7:53 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Less than a minute on Google gave me:
Quote:
Integer.parseInt(x) converts String to int

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
chanchal
PostPosted: Thu Mar 25, 2004 9:08 am    Post subject: Reply with quote

Apprentice

Joined: 30 Jan 2004
Posts: 38

I have already tried it but it gives NumberFormatException.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 25, 2004 9:42 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

chanchal wrote:
I have already tried it but it gives NumberFormatException.


Then your string is not a number.

This is not an MQSeries Java/JMS question.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Mar 26, 2004 3:43 am    Post subject: String to Int conversion Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

I have stumbled against a similar scenario where a byte array contained a binary number.

Iterate through your array and write out each byte as hex (check out the byte methods). Then you can use Integer.decode method. Depending on your operating system you may have to reverse the order in the array(least significant/most significant) bit.

I used such a technique to decode the reason code from the dead letter queue header in java

Hope it helps
F.J.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Converting String to int
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.