Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By Roshani
  • 1 Post By trcooke

Thread: How to make filename in sequence in 5 digit

  1. #1
    Roshani is offline Member
    Join Date
    Jul 2016
    Posts
    18
    Rep Power
    0

    Default How to make filename in sequence in 5 digit

    Hi !

    I have one integer named frameCnt.

    I have one String named fileName

    pls. look this code.

    Java Code:
    frameCnt++;
    fileName = "frame" + String.ValueOf(frameCnt) + ".png" ;
    now file is "frame1.png"

    next time file name will be "frame2.png"


    I want to get file name like "frame00001.png", "frame00002.png" ....

    like this.

    How can i do it ?
    mmirbekian likes this.

  2. #2
    trcooke is offline Tim Cooke
    Join Date
    Jul 2014
    Location
    Belfast
    Posts
    101
    Rep Power
    0

    Default Re: How to make filename in sequence in 5 digit

    Instead of using String.valueOf(), try using String.format(). For example:

    Java Code:
    String.format("%05d", frameCnt)
    Which translates to
    % - begin format string
    0 - pad with zeros
    5 - width, minimum number of characters to be written
    d - decimal integer type
    mmirbekian likes this.

  3. #3
    Roshani is offline Member
    Join Date
    Jul 2016
    Posts
    18
    Rep Power
    0

    Default Re: How to make filename in sequence in 5 digit

    Thanks

    its working.

  4. #4
    trcooke is offline Tim Cooke
    Join Date
    Jul 2014
    Location
    Belfast
    Posts
    101
    Rep Power
    0

    Default Re: How to make filename in sequence in 5 digit

    You're welcome.

Similar Threads

  1. Replies: 1
    Last Post: 01-23-2013, 06:06 PM
  2. Eclipse Pluggin to make Sequence Diagram
    By blackz in forum Eclipse
    Replies: 0
    Last Post: 04-16-2012, 04:26 AM
  3. Output Jar Filename
    By CuddlyKittens11 in forum NetBeans
    Replies: 0
    Last Post: 04-25-2011, 01:09 AM
  4. Replies: 0
    Last Post: 01-23-2011, 12:37 AM
  5. Linked list sequence and array sequence
    By Predz in forum New To Java
    Replies: 1
    Last Post: 12-31-2009, 01:30 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
  •