Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Concantinate Leading zeros when extracting data from a SQL query and exporting that data to a ".txt" file

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Location
    Atlanta
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Concantinate Leading zeros when extracting data from a SQL query and exporting that data to a ".txt" file

    A sample of my code is below, but when some of the numbers are exported, they will have a "0" in front because I am pulling 5 numbers. I need to get rid of leading 0 if that number is say 4951 it will automatically place a 0 in front making it 04951.

    //Concatinate Client and Matter numbers to 4 digits
    if ( Matter_Number.length() > 5 )
    {
    Client_Number = Client_Number.substring( Client_Number.length()-5, Client_Number.length() );
    Matter_Number = Matter_Number.substring( Matter_Number.length()-5, Matter_Number.length() );
    }
    else
    {
    System.out.println( "Error! Matter too short" + Matter_Number );
    }

    print_writer1.println( Client_Number + "|" + Client_Name.trim() + "|" + Matter_Number + "|"+ Matter_Name.trim() + "|" + Practice_Number );


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Concantinate Leading zeros when extracting data from a SQL query and exporting that data to a ".txt" file

    If the number was an int it wouldn't be possible to have leading zeroes.
    Improving the world one idiot at a time!

Similar Threads

  1. Hexadecimal to Binary WITH leading zeros???
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 6th, 2012, 09:27 PM
  2. Problem extracting data from file
    By hello_world in forum File I/O & Other I/O Streams
    Replies: 17
    Last Post: August 21st, 2011, 09:35 PM
  3. Reading file Data into a "struct"
    By Brandt in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: February 9th, 2011, 10:02 AM
  4. Need something like a "Hashtable<String[], Integer>" kind of data type @@
    By Albretch Mueller in forum Java Theory & Questions
    Replies: 2
    Last Post: November 27th, 2010, 10:24 PM
  5. Replies: 4
    Last Post: August 13th, 2009, 05:54 AM

Tags for this Thread