• Post Reply Bookmark Topic Watch Topic
  • New Topic

files  RSS feed

 
Janaranjani K
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to convert a bytearray into a single integer.
 
Ram Hebbale Hiriyanna
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't.
 
Janaranjani K
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks okay ,then how can i convert a String object into a int
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ranjani Kannan:
thanks okay ,then how can i convert a String object into a int


Use Integer.parseInt(String s) method. If the string does not contain a parsable integer it will throw NumberFormatException.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to convert a bytearray into a single integer.

That depends on what you want exactly. Is it a byte array of arbitrary length? If I give you a concrete example, can you tell me what integer value you would expect? Here it is:
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranjani Kannan: How to convert a bytearray into a single integer.

Ram Hebbale Hiriyanna: you can't

This is not entirely true. As Jesper implies, we need more details to understand what you want to do. You can easily use a byte array to represent a single number. The question is what representation are you using? Perhaps Ram meant there is not a method in the Java API to do this. You will need to define what the byte array represents in order to answer this question meaningfully.

Layne
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!