This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

byte[] to int  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i convert byte[] array to int can anyone please help me.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can convert byte[] to int[] and not to int directly.

Refer the following code and let me know if I understood your requirement clearly.

 
Sandeep Sirsekar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya that's perfectly fine you are upcasting byte data-type to int data-type.
but what my need is

someMethod(byteArray);//this method is provided by sun in some interface so i can't change.

i want to convert these bytes to string(that i know) but to convert it to int data-type is not known to me.
so that is the problem
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


does it work?
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sandeep Sirsekar:
ya that's perfectly fine you are upcasting byte data-type to int data-type.
but what my need is

someMethod(byteArray);//this method is provided by sun in some interface so i can't change.

i want to convert these bytes to string(that i know) but to convert it to int data-type is not known to me.
so that is the problem



If you have a method that can convert a byte array to a String, convert it to a String and then convert the String to an integer.

int converted = Integer.parseInt(convertedString);
 
The moustache of a titan! The ad of a flea:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!