1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Test {

    // First run this, then attrib +h on the file, then run.
    // Then you get the error, then attrib -h, and the erros goes away

    public static void main( String[] args ) {
        try {
            File file = new File("C:\\file1.txt");
            //file.isHidden();
            FileWriter fw = new FileWriter( file );
            PrintWriter out = new PrintWriter( fw );
            out.println( "This is a test 2" );
            out.close();
        } catch( IOException e ) {
            e.printStackTrace( System.out );
        }
    }

}