• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

creating hidded file

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear all..

want to create hidden files , Can anyone provide some sample code for doing this.
thanks..
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an OS-dependent thing; there's no Java API for it. On UNIX, by convention, hidden files are those whose names start with a dot (.). Does Windows have hidden files? If so, if it's name-based, then just use the appropriate names; otherwise, perhaps you can run some Windows command using Runtime.exec() to make files into hidden files.
 
Marshal
Posts: 26293
80
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Windows command to make files "hidden" is the ATTRIB command. Any Windows file can be made hidden or not hidden.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you can use windows command to create hidden folder which is "ATTRIB +h"
and here sample code


import java.io.*;
public class Class1
{
public static void main( String[] argv )
{

String folderName = "\\whatevere";
File fp = new File(folderName);
fp.mkdir();

String command = "ATTRIB +h \\"+folderName;

try
{
Process process = Runtime.getRuntime().exec("cmd /C "+command );
process.waitFor();
System.out.println("Exit code is " + process.exitValue());
}
catch ( Exception ioex )
{
ioex.printStackTrace();
}
}
}
 
tariq shadid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and i write this code in unix to create hidden folder which is:

boolean setHidden(boolean value)
{
if (value && !isHidden())
return renameTo('.' + getPath());
else if (isHidden())
return renameTo(getPath().substring(1));
else
return false;
}

but it doesnt work

can any body help me

Tariq Shadid
PHP DEVELOPER
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by tariq shadid:

but it doesnt work



Doesn't work in the sense that it doesn't compile, or given appropriate utility methods to make it compile, it doesn't do the right thing?
 
reply
    Bookmark Topic Watch Topic
  • New Topic