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 11 of 11

Thread: Renaming a file

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Renaming a file

    how can we rename the scanned image file from scanner which is by default scan_01

    is their any api which can rename the scanned o/p file

    --- Update ---

    with help of java


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    646
    My Mood
    Sleepy
    Thanks
    10
    Thanked 95 Times in 88 Posts

    Default Re: Renaming a file


  3. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Renaming a file

    Quote Originally Posted by dude001 View Post
    how can we rename the scanned image file from scanner which is by default scan_01

    is their any api which can rename the scanned o/p file
    renameTo of java.io.File. But beware, as javadoc states, that "Many aspects of the behavior of this method are inherently platform-dependent"
    Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginners – My new project Java Examples on Google Code

  4. The Following User Says Thank You to andbin For This Useful Post:

    dude001 (February 25th, 2014)

  5. #4
    Junior Member
    Join Date
    Feb 2014
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Renaming a file

    bro u didn't get me
    i mean to say that when person put a sheet in the scanner machine, a scanner gui is appeared which ask in what format we need to save the scanned image
    so it just save the scanned image as scan_01.jpg

    i m creating an application where a gui will be present & person will fill the form in the gui, based on the information provided by person i want to rename the scanned image but scanner provide a default name

    So tell me how can i do that

    --- Update ---

    ok i got it

  6. #5
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Renaming a file

    Quote Originally Posted by dude001 View Post
    i want to rename the scanned image but scanner provide a default name
    What do you want to control? The GUI of the scanner software? (Epson software has its scanner GUI, HP has its own, etc...). You can't (hardly) control that GUI directly, since it's different for each scanner producer.
    At native O.S. level there are apposite APIs, the TWAIN API and on Windows the WIA (Windows Image Acquisition) and others. This at native level (and I don't remember now if these APIs can control the filename).

    At Java level there is nothing "standard" and well known for this. There is something (please see this search on Google) but I don't known and never used.

    So sorry, you are asking an "hard" thing.
    Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginners – My new project Java Examples on Google Code

  7. #6
    Junior Member
    Join Date
    Feb 2014
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Renaming a file

    yes i m working with jtwain

    --- Update ---

    till now i m able to understand how to hide the scanner gui

  8. #7
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Renaming a file

    Quote Originally Posted by dude001 View Post
    yes i m working with jtwain
    You could tell this before .....

    Have you looked at page 15 of the developer guide of JTwain? It tells how to save the image to a file programmatically.
    Note: I never used JTwain ... It took me just 3 minutes to find this ....
    Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginners – My new project Java Examples on Google Code

  9. #8
    Junior Member
    Join Date
    Feb 2014
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Renaming a file

    actually i need to study the methods of jtwain first

  10. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,317
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: Renaming a file

    Another approach could be to use a FileSystem WatchService to wait for the creation of the file.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #10
    Junior Member
    Join Date
    Feb 2014
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Renaming a file

    what is that can u explain it more

  12. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,317
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: Renaming a file

    See the Java SE 1.7 API doc for those classes: FileSystem and WatchService
    for a description of what they can do.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Run a jar file inside a batch file with Windows 7 Task schduler
    By kingnachi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 15th, 2012, 10:20 AM
  2. [SOLVED] file deletion/renaming not successful, don't think I have any streams open
    By Bottleskup in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 21st, 2011, 05:14 PM
  3. Renaming labels & text boxes
    By fride360 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 03:11 PM
  4. renaming/deleting file
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 15
    Last Post: January 15th, 2011, 12:18 AM
  5. Replies: 8
    Last Post: January 6th, 2010, 09:59 AM