Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!file.exists() && !file.createNewFile()) {
- System.err.println("Error with output file: " + outFile
- + "nCannot create new file.");
- continue;
- }
- file.getParentFile().mkdirs()
- try {
- if(!file.createNewFile()) {
- System.out.println("File already exists");
- }
- } catch (IOException ex) {
- System.out.println(ex);
- }
- if (file.getParentFile() != null && !file.getParentFile().mkDirs()) {
- // handle permission problems here
- }
- // either no parent directories there or we have created missing directories
- if (file.createNewFile() || file.isFile()) {
- // ready to write your content
- } else {
- // handle directory here
- }
- if (file.exists() && !file.isFile()){
- //handle directory is there
- }else if(!file.createNewFile()) {
- //as before
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement