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.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Java code for hide a file

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Thanked 0 Times in 0 Posts

    Post Java code for hide a file

    Hi, there
    I want to hide a file in windows 7 using a java.
    But I didn't find an effective way to do so.
    Can somebody post a sample code to hide a file using java in windows 7?
    I'm using JDK 7
    Thank you......

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: Java code for hide a file

    Please give more detail. You might first try a search with your favorite search engine to see if you get any suggestions and then come back when you can give more info about what you're trying to do. Maybe hiding a file is one of a number of other possible solutions (or not), so if you describe what you're trying to do, someone may have other ideas they could share with you.

  3. The Following User Says Thank You to GregBrannon For This Useful Post:

    Cruger (October 15th, 2013)

  4. #3
    Junior Member
    Join Date
    Sep 2013
    Thanked 0 Times in 0 Posts

    Default Re: Java code for hide a file

    @GregBrannon Let's say I have a text file named Main.txt. And I have a java code in Hide.java in the same folder. What I want is when I'm executing the Hide.java I want to hide the Main.txt file.
    By searching net I have come up with a code. I tried it to use, But every time I compile the code it gives an error.
    Here is the code:
    Path path = FileSystems.getDefault().getPath("directory", "hidden.txt");
    Boolean hidden = path.getAttribute("dos:hidden", LinkOption.NOFOLLOW_LINKS);
    if (hidden != null && !hidden) {
    path.setAttribute("dos:hidden", Boolean.TRUE, LinkOption.NOFOLLOW_LINKS);

    Please make a simple program using this code(or any other way you know). I just want to learn how to make a program to hide a file

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,428 Times in 2,379 Posts

    Default Re: Java code for hide a file

    Go read the API doc for the classes and methods you trying to use. The posted code does not compile.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java code Split text file into multiple text file
    By jayraj in forum What's Wrong With My Code?
    Replies: 26
    Last Post: April 19th, 2013, 06:14 AM
  2. Hide forms in java application
    By jonmuthee in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 7th, 2012, 10:20 AM
  3. Trouble Porting my Java File Reading Code to Android Code
    By Gravity Games in forum Android Development
    Replies: 0
    Last Post: December 6th, 2012, 04:38 PM
  4. Java I/O File code; how to read/write file
    By ryu2le in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 18th, 2011, 05:51 PM