Examples of CannotWriteFileException


Examples of FileOperations.Exceptions.CanNotWriteFileException

        BufferedWriter output = null;
        try {
            output = new BufferedWriter(new FileWriter(path));
            output.write(text);
        } catch (IOException ex) {
            throw new CanNotWriteFileException("Cannot write file \"" + path +
                    "\"");
        } finally {
            try {
                if (output != null) {
                    output.close();
                }
            } catch (IOException ex) {
                throw new CanNotWriteFileException("Cannot write file \"" + path +
                        "\"");
            }
        }
    }
View Full Code Here

Examples of it.unina.seclab.jafimon.exceptions.CannotWriteFileException

   
    File f = new File(fullName);
   
    // Mi assicuro che il file non esista gia'
    if (f.exists())
      throw new CannotWriteFileException(cName, "File already exists");
   
    // Ora creo le cartelle intermedie (se necessario)
    if (!new File(fullName.substring(0, fullName.lastIndexOf(File.separator))).mkdirs())
      throw new CannotWriteFileException(cName, "Cannot create intermediate directories");
   
    // Mi assicuro di poter scrivere sul file
    try {
      if (!f.createNewFile() || !f.canWrite())
        throw new CannotWriteFileException(cName, "Unable to write to file (probably read-only)");
    } catch (IOException e) {
      throw new CannotWriteFileException(cName, e.getCause() + " - " + e.getLocalizedMessage());
    }
   
    ConfigurationParser.save(xmlDocument, fullName);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.