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

    Default problem in my application

    it's my first time to make an applicaion using java under linux...

    when file chooser appear i want the user to choose any file to hide it by adding "." at start of the name of file

    this is the action
    Java Code:
      private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            int returnVal = hide.showOpenDialog(this);
            if (returnVal == JFileChooser.APPROVE_OPTION) //press open
            {
                File file = hide.getSelectedFile();
                file.renameTo(new File("."+file.getName())); //hide file add . to it's name
               
            }
            else    { // cancel on file chooser to hide file
                
            }
    
        }
    i want to hide any file in any partition ???????? help please

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    What happens when you run that?
    You haven't told us what the problem is...

    However, it looks to me like you're renaming the file at the same time as moving it to the root directory (I think). You haven't got the path in the file name you're giving to the constructor.

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

    Default

    i have two problem

    1- i can hide files in root directory only.
    2- i don't want to move the file to the root directory .

    please i need help

  4. #4
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    305
    Rep Power
    6

    Default

    When you construct the renamed file make sure to give the entire path to the old file.

    I would try getting the Absolute Path(getAbsolutePath()) of the selected file, remove the name and extension, and add the new name with the preceding "." character.

Similar Threads

  1. URL Problem with IE7 in my struts Application
    By SreenivasGurramkonda in forum Web Frameworks
    Replies: 0
    Last Post: 11-27-2008, 08:14 AM
  2. Problem running a java desktop application
    By chris@gaiag.net in forum AWT / Swing
    Replies: 2
    Last Post: 08-24-2008, 04:24 AM
  3. Problem In Web Application
    By sharfi in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 04-16-2008, 10:36 AM
  4. problem locating file in web application
    By Rem in forum New To Java
    Replies: 0
    Last Post: 11-09-2007, 04:00 PM
  5. Problem when sending application server with RAD 6
    By Marcus in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 06:44 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
  •