Java character validation

Hi there,
I know this question may seem very elementary, but I was wondering. Would anyone know the opposite of:
Character.isDigit(myVariable.charAt(0))I tried using this below but it didn't do anything:
!Character.isDigit(myVariable.charAt(0))Is there something that I am doing wrong?
Thanks

Hi,
It seems that I have discovered what the issue was. I was actually using the above code in a conditional in collaboration with a string length check such as the one below:
(myVariable.length() != 1) && (!Character.isDigit(MyVariable.charAt(0)))It was however not validating for a single letter that was typed. What I should have done as I later discovered was
(myVariable.length() != 1) || (!Character.isDigit(MyVariable.charAt(0)))So that it validates either condition and does not exhibit weird behaviour. However, I wonder if someone could please explain why in the previous syntax it was not validating for a single letter typed.

Similar Messages

  • Java Character set error while loding data using iSetup

    Hi,
    I am getting the following error while migrating settup data from R12 (12.1.2) Instance to another R12 (12.1.2) Instance, Both the Database has same DB character set (AL32UTF8)
    we are getting this error while migrating any setup data
    Actual error is
    Downloading the extract from central instance
    Successfully copied the Extract
    Time taken to download Extract and write as zip file = 0 seconds
    Validating Primary Extract...
    Source Java Charset: AL32UTF8
    Target Java Charset: UTF-8
    Target Java Charset does not match with Source Java Charset
    java.lang.Exception: Target Java Charset does not match with Source Java Charset
         at oracle.apps.az.r12.common.cpserver.PreValidator.validate(PreValidator.java:191)
         at oracle.apps.az.r12.loader.cpserver.APILoader.callAPIs(APILoader.java:119)
         at oracle.apps.az.r12.loader.cpserver.LoaderContextImpl.load(LoaderContextImpl.java:66)
         at oracle.apps.az.r12.loader.cpserver.LoaderCp.runProgram(LoaderCp.java:65)
         at oracle.apps.fnd.cp.request.Run.main(Run.java:157)
    Error while loading apis
    java.lang.NullPointerException
         at oracle.apps.az.r12.loader.cpserver.APILoader.callAPIs(APILoader.java:158)
         at oracle.apps.az.r12.loader.cpserver.LoaderContextImpl.load(LoaderContextImpl.java:66)
         at oracle.apps.az.r12.loader.cpserver.LoaderCp.runProgram(LoaderCp.java:65)
         at oracle.apps.fnd.cp.request.Run.main(Run.java:157)
    Please help in identifying and resolving the issue
    Sachin

    The Source and Target DB character set is same
    Output from the query
    ------------- Source --------------
    SQL> select value from nls_database_parameters where parameter='NLS_CHARACTERSET';
    VALUE
    AL32UTF8
    And target Instance
    -------------- Target----------------------
    SQL> select value from nls_database_parameters where parameter='NLS_CHARACTERSET';
    VALUE
    AL32UTF8
    The Error is about Source and Target JAVA Character set
    I will check the Prevalidator xml from How to use iSetup and update the note
    Thanks
    Sachin

  • How to create security character validation to avoid automated programs

    Hi All,
    I am developing a web page for creating user accounts. I would like to do the security character validation to avoid the misuse from automated programs.
    This is what you may have seen on all popular web pages where you are asked to enter a scrambled set of characters into a text field before submitting your request.
    Please provide any samples or direct me where I can get some help on this.
    Your help is greatly appreciated.
    TIA,
    CK

    Why look for samples when u can can use ur own logic and thinking ?
    My approach ...
    1) Create a lot of scambled images having alphabets like 'rhoit' , 'rohit' ..
    File naming convention should be same as the text. Ex: rhoit.jpg, rohit.jpg ...
    2) Add the images names into a table and then populate a HashMap / ArrayList containing the image names
    3) Randomly pick some artibitrary element from the Arraylist and display the corresponding image in the create user accounts page.
    3) Compare the image name with the inputed text value for a match. The expected value should be set in request parameter.
    4) Handle the success/failure condition.
    I hope that should work fine.
    Regards
    -Rohit

  • ItemDetails WD Java - External Validation

    Hi,
    Has anyone used WD JAVA External Validation with Taxonomy table?
    Everything is ok with plain tables, but when I assign WdCompsUserExits to ItemDetails Component connected with taxonomy table, I have an error: "Illegal field [Parent] found in XSD document. ."
    As I understand, WD component is trying to convert data record to xml which has to be passed into UserExit class but cannot process field [Parent].
    So, is it possible to use "External Validation" with taxonomy tables?

    Timur Semenchuk wrote:
    > We are trying to reproduce the issue creating a new components based on custom validation, but we are still without any success.
    > Have you reproduced the issue with a new DC?
    Do you mean that this issue has only appered in one DC, while with newaly created everything is ok?
    I hasn't checked this with other DCs... We have some serious system landscape changes going on, so there is no chance to test anything right now.

  • Java Character Values

    Hi ,
    Please look into my following java programs:
    public class Test{
    public static void main(String args[]){
    StringBuffer sb = new StringBuffer();
    for(int i = 32;i<256;i++){
       sb.append((char)i);
       doThis(sb.toString());
    public static void doThis(String str){
      byte arr[] = str.getBytes();
      int len = arr.length;
         for(int i =0;i<len;i++){
          char ch = (char)arr;
    int ii = (int)ch;
    System.out.println("character "+ch+ " value "+ ii);
    when I run this program I get the output
    as
    character A value 65
    once the character value reaches 127, then it prints as follow for next 32 enteries that is untill character actual value is 159..
    character ? value 63
    after characters actual value becomes more than 159 that it gives me huges vaules like as below:
    character ? value 65440
    character ? value 65535
    any idea why?
    I want to print the exact value of the characters?
    thanks & Regards,
    Akhil

    char values are not the same thing as byte values in Java. Characters take 16 bit UNICODE values which represent not just the regular latin alphabet but all kind of exotic characters including Greek, Arabic, Hebrew, Chinese and so on.
    When reading and writing text files these UNICODE characters have to be translated from or to byte values. The translation can use many different schemes. There are character encoding schemes designed for various national requirements, for example one where the bytes in the range 128-255 represent Greek characters. There are also international schemes like UTF-8. If you do an operation that changes bytes to characters or characters to bytes (like getBytes()) you generally have the option of specifying a scheme. If not the system uses a default based on your machine's location information.
    In your case I guess the default is ASCII in which only characters up to 127 have valid mappings.
    Had you put
    byte arr[] = str.getBytes("ISO-LATIN-1");I think you'd get something more like what you expected.

  • Special Character Validation and Reset Focus

    Hi All,
    I have developed an Webdynpro JAVA Application which carries many input Fields.
    Client side Validations needs to be handled for Special Character Restriction for each of the Fields.
    Validation handled through OnEnter or OnChange Events of a Particular Field shows the exception but clicking other fields made the exception ignored.
    My Requirement goes this way.
    field1
    field2
    field n
    Validation Button
    On click of Validation button exception should be raised for all the Fields that has invalid Characters .
    It Should be displayed in Message Area( Using MessageManager) which should carry Field Name causing the Exception. On clicking the Exception it should take the Cursor the Erroneous Field.
    Kindly share the Methods of any standard Interface which does this job or customized methods if any?
    Best Regards,
    Suresh S

    try WDPermanentMessage

  • Special character Validation: error

    HI Guys,
    I wrote a validation to restict the use of special chracters.
    Its a formula based validation, both REAL TIME and BATCH, on the Node.
    HasCharacters(Custom.EPMA_Alias, ["]).
    However, when I go to put an Alias on a member, it tells me there is a special character in this, but there is not.
    I also tried HasCharacters(PropValueCustom.EPMA_Alias0, ["]) with same results.
    I also need to add the following characters:
    |
    Thank you for all your help!.

    Hi,
    DRM will not support the syntax ["], instead try somethinug like this for your validation logic-
    And(
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),|,,T))),
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),",,T))),
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),%,,T))),
    Equals(Integer,Length(PropValue(Custom.Prop)),Length(ReplaceStr(PropValue(Custom.Prop),*,,T)))

  • Java Mapping (Validation)

    Hi Guys
    Validations using Java for those not having PI7.1
    I followed this blog for validation of XML.
    I have coded the JAVA Program in NWDS as per the blog, all fine but am not sure about the schema step.
    What i did was:
    1) Exported the .xsd of the Message type.
    2) Then Schema.xml file creation i am not sure of it
    Do any one know how to do that , and what is the purpouse of the Schema method in the Java Mapping.
    Is this blog does a input initerface format check and write in to a log.
    But cannot we do this with the help of Alert by triggering mails ??
    Can we achieve element level vaslidation (to all element of the XML) using this method.
    Kindly share u r views
    Srini

    Hi Santosh,
    Thx for u r reply.
    I understood what u r saying .
    One more question :
    See u r Doc is validating particular element , date and time using api.All good, what if i need to validate entire XML Elements , should i repeat the same for entire element.
    i was so curious with his blog because , it was generic and moreover i thought i can validate entire XML , by not sticking to particular element.
    What is IA ?? U Memtioned ??
    Could above requirment can be achieverd r else i should get each element and validate , no other go
    based upon on the outbound interface
    regards
    srini

  • Java DTD validation

    I am trying to validate an XML using a DTD which is already created, In the code below i would like to validate the XML. I have looked at a number of websites etc but i cannot work out how to put in the validation can someone please help. I am pulling my hair out.
    public class validation {
    BufferedReader in;
    StreamResult out;
    Document xmldoc;
    Element root;
    String xmlString;
    public static void main (String args[]) {
    new validation().doit();
    public void doit () {
    try{
         StringBuffer sBuffer = new StringBuffer();
         String str;
    in = new BufferedReader(new FileReader("clinicSchedule.xml"));
    out = new StreamResult("data.xml");
    while ((str = in.readLine()) != null) {
              System.out.println(str);
    sBuffer.append(str);
         in.close();
    initXML(sBuffer.toString());
    transformXML();
    catch (Exception e) { e.printStackTrace(); }
    public void initXML(String sFinalXML) throws ParserConfigurationException{
    // JAXP + DOM
    try
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = factory.newDocumentBuilder();
              factory.setIgnoringComments(true); // We want to ignore comments
              factory.setNamespaceAware(true);
              factory.setValidating(true);
              // Now use the factory to create a DOM parser
              DocumentBuilder parser = factory.newDocumentBuilder();
              System.out.println(sFinalXML);
              xmldoc = parser.parse(new InputSource(new StringReader(sFinalXML)));
         }catch ( SAXParseException spe ) {
              System.err.println( "Parse error: " +
              spe.getMessage() );
              System.exit( 1 );
         catch (Exception ex) {
              ex.printStackTrace();
         public void transformXML()
              try{
                   //Define source and destination Streams
                   DOMSource domSource = new DOMSource(xmldoc);
                   StreamResult myDestination=new StreamResult("output.html");
                   StringWriter stringWriter=new StringWriter();
                   //StreamResult myDestination=new StreamResult(stringWriter);
                   //Define XSL source stream
                   StreamSource myXSLSource=new StreamSource("emailStyle.xsl");
                   //Create Transformer from Factory
                   TransformerFactory myFactory =TransformerFactory.newInstance();
                   //Transfooooooorm!!!
                   Transformer myTransformer = myFactory.newTransformer(myXSLSource);
                   myTransformer.transform(domSource, myDestination);
                   //xmlString=stringWriter.toString();
              }catch(Exception e){
                   e.printStackTrace();
    }

    There's a number of posts on this topic, so I'm not going to repeat it here. Please, check the following entries in this forum:
    http://forum.java.sun.com/thread.jsp?forum=34&thread=158734
    http://forum.java.sun.com/thread.jsp?forum=34&thread=159320
    http://forum.java.sun.com/thread.jsp?forum=34&thread=172123
    http://forum.java.sun.com/thread.jsp?forum=34&thread=153776
    Good luck and - please - go easy on your hair.

  • Java compiler validation

    I've developed a java compiler in java that will be used in a tool to teach java programming. I'd like to test the compiler with an independent set of programs.
    Anyone know of a free/inexpensive compiler validation suite of programs?
    Many thanks.
    Lindsey Ford

    Hey Keith,
    You may want to post this question on the jboss community forum. No idea what's going on here...
    Bob

  • Japanese character validation

    Hi guys,
    The app I'm working on needs to support some entity names containing either Japanese characters or English characters. I need a validator method that reports whether the name that the user chose is valid or not.
    Here's a snippet:
    static boolean validate(String nameToValidate) {
           char[] arr = nameToValidate.toCharArray();
           for (int i = 0; i < arr.length; i++) {
                   if (!Character.isLetterOrDigit(arr))
                        return false;
    return true;
    That's ok if my name supports only letters and digits, but it should also support ':' (colon), '_' (underscore), '-'(dash) and '.' (dot), AND their Japanese versions. How should I do the comparisons in this case to make sure arr[i] is an accepted character? Using == '-' is obviously not an option, and I'd hate it if I had to depend on some hardcoded Unicode values. Any ideas?
    Thanks!

    Idea: take all allowed characters, save the String to a properties file, and check for each letter of the username whether it's in that String.

  • DB procedure validation versus JAVA method validation

    Hi ,
    We have an application that is developed with Oracle Forms as well as Java (ADF )
    Now since ADF is the newer application, it was told to reduce the development time but provide efficient code. Now with Forms each field validation called a procedure and returned an error.
    For example if Name is validated, They have a procedure VALIDATE_NAME proc. Why they have separated this is cause based on different customers and different products, the name validation differs. So the in parameters are Field val, Product, customertype... etc. Like this, there are 20 VALIDATE_FIELD procedures for respective fields.
    Now to reduce duplication, I can call each procedure on each field. but that would means 20 DB additional calls for each procedure. If I write this logic in java it means I increase development time and probably increase probability of error.
    Which is the best practice for VALIDATION.

    Hi,
    you already mentioned the pros and cons of the approaches. I don't think that it is good practice to directly call the PLSQL validation from Java as it means you wont be able to change it easily in the future. I would look for an abstraction layer that initially (for the time being) accesses the database for validation (maybe caching some validation policies upon application instance start) and later then can be changed to use pure Java validation rules. One thing coming to my mind would be something like a rules engine that reads the validation conditions from the database and that is accessed from Java. If your manager says you should reduce development time then my impression is that the choice is not yours and you will have to use the database (though it feels wrong).
    Frank

  • How can i Make sys's java classes valid?

    I use Oracle 8.1.8.
    All the java classes in sys are invalid.
    How can I make it valid?
    thanks!

    Dear Chris,
    Sorry to disturb you.
    As I didn't browse Metalink yet, How could I browse METALINK With below Category?
    Thanks in advance,
    Orahar.

  • Character Validation Performance

    I need to validate some strings that I'll be writing to files. I need to validate that the strings only contain the following characters:
    {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
    'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
    'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
    'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.',
    '-', '(', ')', '/', '=', ',', ' '}The only way I can think to do this is to convert each string into a char[], and then loop through the array to see if each character is valid, but I'm worried that this is going to give really bad performance. What's the fastest way to validate the strings?
    p.s I can't use 1.4 so the regex package isn't an option and I can't validate the Strings on input either (they're from an external source).

    After writing a test class I found that I was probably over concerned about the performance hit:
    public class Tester {
      private static final char[] valid = new char[] {'a', 'b', 'c', 'd', 'e',
           'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
           'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
           'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
           'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '.', '-',
           '(', ')', '/', '=', ','};
      private static final String invalidString =
           "a!a?s$f%f^r&g*t(erfe)_ee+}ee{er~yu@:?k>kik<uluil|oo#454'.;jy5[";
      public Tester() {     
        final long start = System.currentTimeMillis();
        for (int x = 0; x < 100000; x++) validate(invalidString);
        System.out.println(System.currentTimeMillis() - start);     
      public static void main(String[] args) {
        new Tester();
      private String validate(String s) {
        char[] validate = s.toCharArray();
        for (int x = 0; x < validate.length; x++) {
          boolean found = false;
          final char c = validate[x];
          for (int y = 0; y < valid.length; y++) {
            if (c == valid[y]) {
              found = true;
              break;
          if (!found) validate[x] = ' ';
        return String.valueOf(validate);
    }I found that 100000 iterations took approx 1400 ms (jdk 1.3). Is there an easy way to make that method any faster?

  • Java input validation with regular expression

    I am trying to make sure the user can only enter numbers 0 - 100, can any of you Java geniuses give me a hint. My regex matches the inputs I want, but when I enter a '9' I encounter an error when I cast the string to a double. Actually the input value is never assigned to the perc variable, but only when the input is a single digit. Here' s the piece of code that's giving me this headache:
    while(!in.hasNext("[0-9]")){
         try {
              perc = in.next("[0-9]{1,2}|100");
              break;
         } catch (InputMismatchException e) {
              System.out.println("Bad Input - Try Again");
              perc = in.next();
    dblPerc = Double.parseDouble(perc);And here's the error:
    Exception in thread "main" java.lang.NumberFormatException: empty String
            at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
            at java.lang.Double.parseDouble(Double.java:510)
            at applicant_database.View.showInput(View.java:46)
            at applicant_database.View.main(View.java:101)

    Add debugging code to your program to see what you're getting.

Maybe you are looking for

  • Cannot delete entries from custom Infostructure using OLIX

    Hi, I have created a custom info structure S970 for MRP. The data is being populated to this info structure using an ABAP program which reads from an excel file input by the user. Insert / Modify are used to write from itab to S970 in the program. Th

  • Printing Crystal Reports without calling Adobe Acrobat preview window

    Post Author: akurilin CA Forum: General Hi, each time a click a Print icon in a Crystal report preview toolbar, it opens a dialog box which opens an Adobe Acrobat preview window. Is it possible to print a Crystal report without calling Adobe Acrobat

  • RMI: can a client support cuncurrent calls from others client?

    Hi, I'm trying to build a simple peer 2 peer system. My clients, when registering to the server, are passing a ResourceList (class that extends Remote) to the server, so that the server has a complete list of all the resources of the connected client

  • Error message pops up when opening camera

    Hi Sony, I bought my xperia z3 on saturday from India. I checked the phone and it was perfect and everything goes fine. On sunday i updated my phone through PC companion( when i connected it shows "a new update is available for my phone") but after t

  • How to pass dynamicaly values :new.COLUMN_NAME from TRIGGER?

    Hello folks, I have 1 configuration table, which stores information about other table's columns in case when special validation to that column should be performed by validation process. Then I need to create a before insert, update trigger for valida