Code example for FilePermission

0
    private boolean canPrintToFile() { 
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            try { 
                sm.checkPermission(new FilePermission("<<ALL FILES>>",
                        "read,write")); 
                return true; 
            } catch (SecurityException e) {
                return false; 
            } 
        } 
        return true; 
    } 
 
    /* 
     * just list of all doc flavors from specification 
     * it is used in getSupportedDocFlavors() method 
     */ 
    private static DocFlavor[] ALLDOCFLAVORS = { DocFlavor.BYTE_ARRAY.TEXT_PLAIN_HOST,
            DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8, 
            DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_16,