Auto closing of Elements in try block
New Input Output type Multi exceptions Diamond operator </span>
try (BufferedReader br = new BufferedReader(new FileReader(FILE_NAME));) {
System.out.print(br.readLine());
}
}
Path path = Paths.get(FILE_NAME);
boolean exists = Files.exists(path);
boolean isDirectory = Files.isDirectory(path);
boolean isExecutable = Files.isExecutable(path);
boolean isHidden = Files.isHidden(path);
boolean isReadable = Files.isReadable(path);
boolean isRegularFile = Files.isRegularFile(path);
boolean isWritable = Files.isWritable(path);
long size = Files.size(path);
// Copies a file
Files.copy(Paths.get(FILE_NAME), Paths.get(FILE_NAME_DEST));
// Reads a text file
List<String> lines = Files.readAllLines(Paths.get(FILE_NAME_DEST));
for (String line : lines) {
System.out.println(line);
}
// Deletes a file
Files.delete(path);
try {
} catch(SAXException | IOException | ParserConfigurationException e) {
System.out.print("helloCatch");
// e.printStackTrace();
}
Map<String,String> map = new HashMap<>();
Related Posts via Taxonomies