Results 1 to 4 of 4
  1. #1
    gokulcool is offline Member
    Join Date
    Dec 2008
    Posts
    3
    Rep Power
    0

    Smile Delimite the file using comma

    Hi All,

    This is my first question in this forum...
    I have file with numeros datas(both numeric and characters)
    I want to delimit the file with set of delimiter length like 2,5,1,9,6 etc..

    For example
    if my file like this
    9483trdcvge245621jde

    then i need to insert commas at 2,5,1,9,6 etc..
    then the output will be
    94,83trd,c,vge245621,jde,

    Like this i need..Pls help me to solve this issue..
    Thanks in advance

  2. #2
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    You could use DecimalFormat (I believe it accepts strings) if you know the look of your expected string do something like
    Java Code:
    DecimalFormat df = new DecimalFormat("00,00000,0,000000000,000,")
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    I assume you already have several fields you want to put together. If you have one long string, you will have to break it apart first.

    Just do String output = field1 + "," + field2 + "," + ... ;

    You can also use other characters as well, "\t" (tab) works very well.

Similar Threads

  1. Replies: 2
    Last Post: 04-07-2009, 06:25 AM
  2. Replies: 7
    Last Post: 11-19-2008, 02:09 PM
  3. Replies: 7
    Last Post: 05-23-2008, 03:46 AM
  4. Replies: 1
    Last Post: 05-07-2008, 01:19 AM
  5. Replies: 0
    Last Post: 04-16-2008, 10:58 PM

Posting Permissions

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