FileDocCategorySizeDatePackage
ReadOnly.javaAPI DocExample709Sat Nov 25 12:54:56 GMT 2000None

ReadOnly

public class ReadOnly extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] a)


		File f = new File("f");

		if (!f.createNewFile()) {
			System.out.println("Can't create new file.");
			return;
		}

		if (!f.canWrite()) {
			System.out.println("Can't write new file!");
			return;
		}

		if (!f.setReadOnly()) {
			System.out.println("Grrr! Can't set file read-only.");
			return;
		}

		if (f.canWrite()) {
			System.out.println("Most immutable, captain!");
			System.out.println("But it still says canWrite() after setReadOnly");
			return;
		} else {
			System.out.println("Logical, captain!");
			System.out.println("canWrite() correctly returns false after setReadOnly");
		}