aspose file tools
The moose likes Java in General and the fly likes sorting values in an array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "sorting values in an array" Watch "sorting values in an array" New topic
Author

sorting values in an array

vasantkr kr
Greenhorn

Joined: Jan 25, 2006
Posts: 4
Hi,
I have split strings(multiple) in a string buffer into two parts(arr[0],arr[1]) and stored it in an array.How do i check if the string stored is a date or decimal or a word.
Can anyone give me the solution to it.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

Do you mean by reading a character one-by-one from buffer? You can try parsing, for example using Double.parseDouble() to determine if the string value is a decimal.


My Blog: Down Home Country Coding with Scott Selikoff
Adam Richards
Ranch Hand

Joined: Nov 03, 2005
Posts: 133
If I read the previous post correctly, he is saying to rely on exceptions to detect data types. That would would work on a small scale, but will give performance problems on large systems. For the latter, a better approach is to parse the entries yourself & branch base on the data type you detect.
Harald Kirsch
Ranch Hand

Joined: Oct 14, 2005
Posts: 37
Would "Thursday" be a date or a word. How about 20060130? Looks like a huge number to me, but could as well denote the 30th January 2006.

As you see there no way to prescribe a solution without a more detailed specification. But before posting the spec here, I suggest to have a look at regular expressions.


Harald.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sorting values in an array
 
Similar Threads
Simple problem
Arrays
Converting byteArray in UTF-16 format to String or character.
arrayindexoutofbound exception
Array Problem