This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting String to Integer

 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I'm having a little bit of trouble converting a string a an integer:



If I set string1 = "5" and string2 = "4" the output is "9". But like I excepted it doesn't work when the strings have spaces in them . How do I remove does spaces in the beginning? Does anyone know a built-in method from the APIs or an alternative way around this problem

Thank-you

[edit - change 'quote' tags to 'code' tags]
[ February 29, 2008: Message edited by: fred rosenberger ]
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.trim()
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12021
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Olivier,

I change your post a little. When you want to post code, don't use the 'quote' tags, but the 'code' tags. This will preserve your formatting, making it easier to read.
 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh oops. My bad. Thanks for fixing it
 
Campbell Ritchie
Sheriff
Pie
Posts: 47284
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go through the Integer class; there are probably several methods and a constructor which take Strings as parameters.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic