• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 24207
46
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: 28263
95
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: 24207
46
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic