java - How do you determine the type of data contained in a string? -


I have a method that accepts string logic.

An integer in the string, double, boolean, or just plain old letters and numbers.

I want an easy way to determine what type of string is.

There is a way to catch a bunch of blocks and try to parse it in every type, and if an exception is thrown, then it is probably not that data type. It seems incorrect because it is an intuitive program, not a deterministic program.

If you know how to once you enter the parameter You know, it is ok to parse that type of string and catch the exception - it's fair use of exceptions to capture invalid data (unless you're just trying one type ..)

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -