+ Reply to Thread
Results 1 to 3 of 3

Thread: Java text convertion

  1. #1

    Default Java text convertion

    James, I've done quite a bit of work with Java, including JDBC. Java data conversion normally works quite well. One caution in Java, though. Examine the following syntax: if (myString == "hello") This does not work. This only compares the addresses of myString and the literal constant that contains the word "hello". This was my most common mistake when I was learning Java. Instead, you must use the following: if (myString.equals("hello")) The second problem is that the conversion classes often return data with blank padding. If your field is ten characters long, you might need to compare as follows: if (myString.equals("hello*****")) (Replace the asterisks with blanks.) The other option, provided you are not worried about leading blanks, is to use the trim() method. trim() removes both leading and trailing blanks: if (myString.trim().equals("hello")) Again, be careful, because this will match any of the following fields: hello*****[*]hello****[*]*hello***[*]**hello**[*]***hello*[*]****hello (Again, where the asterisks represent blanks). If none of these work for you, please post your code and let us know what you're doing.

  2. #2
    Guest.Visitor Guest

    Default Java text convertion

    I'm having a problem converting text from the as400 to the java unicode format. What I'm doing is getting the data from physical file using as400 jdbc. I'm then comparing strings from the pc side to the data from the as400 but they will not equate e.g "hello" from the as400 is not = "hello" on the pc. Is this a text type conversion problem and if so how do I fix it?

  3. #3
    Guest.Visitor Guest

    Default Java text convertion

    Thanks, your solution works perfectly :-) Learning java from an RPG background has been interesting.

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 08-02-2005, 09:06 AM
  2. Java Exception Error: java.io.FileNotFoundException
    By brozycki@oldrepnatl.com in forum Java
    Replies: 0
    Last Post: 07-06-2005, 09:30 AM
  3. As400 data Convertion into Xml, tool.
    By Guest.Visitor in forum General
    Replies: 1
    Last Post: 07-22-2003, 12:51 AM
  4. ISO convertion to 6byte date field
    By T.Holt in forum Programming
    Replies: 2
    Last Post: 10-29-2001, 11:07 AM
  5. Crt Scrn/Fld Help text from Std Text fil
    By Guest.Visitor in forum Programming
    Replies: 0
    Last Post: 01-01-1995, 02:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts