Results 1 to 3 of 3
  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default problem in file path

    if i have file path D:\System\file.png

    i want to make new file with this path but put .(dot) at start the file name

    it's convert to D:\System\.file.png

    how can i make this in java

    i need help !!!

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

    Default

    Get the file, rename it and save with the new name. I don't know what's the use of dot, it could be real mess-up naming conversion.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by jperson View Post
    if i have file path D:\System\file.png

    i want to make new file with this path but put .(dot) at start the file name

    it's convert to D:\System\.file.png

    how can i make this in java

    i need help !!!
    A bit of File and String fiddling will do the job:

    Java Code:
    File file= new File(<your file name here>);
    StringBuilder sb= new StringBuilder(file.getAbsoluteFile().toString());
    int i= sb.lastIndexOf(file.getName());
    
    sb.insert(i, '.');
    System.out.println(sb.toString());
    kind regards,

    Jos

Similar Threads

  1. file path
    By ras_pari in forum Advanced Java
    Replies: 2
    Last Post: 10-12-2009, 11:25 AM
  2. reading file from a path
    By new_coder in forum New To Java
    Replies: 5
    Last Post: 08-17-2009, 04:52 AM
  3. Weird path problem when reading properties file
    By jerry_popperq in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 03:32 PM
  4. How to set Image file path
    By anil.bharadia in forum AWT / Swing
    Replies: 1
    Last Post: 01-28-2009, 09:10 PM
  5. file path
    By Arsench in forum New To Java
    Replies: 7
    Last Post: 10-30-2008, 05:39 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
  •