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 Java in General and the fly likes how to find out the datatype 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 » Java in General
Bookmark "how to find out the datatype" Watch "how to find out the datatype" New topic
Author

how to find out the datatype

shyam sunder prasad
Ranch Hand

Joined: Mar 23, 2011
Posts: 62
hi,
how to find out the data type based on data.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3599
    
  14

I guess it depends on the data. Can you be more specific?
shyam sunder prasad
Ranch Hand

Joined: Mar 23, 2011
Posts: 62
suppose,

there is a string s="122.2". so i want to convert it to float type. or based on the date i want to do different operation.

so, is there any method is java to find out what the data type is?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3599
    
  14

Oh, you want Java to interpret your data? No, Java can't do this. You will have to do it yourself. If you have a String and you know ahead of time that it represents a number, you can call a method like Integer.parseInt() to convert the String to an int.

Do you have a specific reason you're asking this question?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
You can probably Google and find a regular expression for floating-point numbers and for integers in a few seconds. That might work. Some of the expressions here are mistaken, but you have a good chance of finding something useful there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to find out the datatype
 
Similar Threads
Connecting To Database
Reading a blob
jsp to pdf
exporting charts to excel spreadsheet
Optimum batch size