Passion of IT

Java 1.7 what’s new

Auto closing of Elements in try block

</span>

try (BufferedReader br = new BufferedReader(new FileReader(FILE_NAME));) {

System.out.print(br.readLine());
}
}

New Input Output type

 


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);

Multi exceptions


try {

} catch(SAXException | IOException | ParserConfigurationException e) {
System.out.print("helloCatch");
// e.printStackTrace();

}

Diamond operator


Map<String,String> map = new HashMap<>();

 

 

No Comments Yet

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="
"> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Comments

Michele Rizzithe website doesn't exist. Ara you a robot? In any case it's difficult that an automatic system writes a comment here since there are two captchas...
Hello there! This is kind of off topic but I need some guidance from an established blog. Is it very hard to set up your own blog? I'm not very t...
We are a group of volunteers and opening a new scheme in our community. Your web site offered us with valuable information to work on. You've done a...
April 2024
M T W T F S S
« Dec    
1234567
891011121314
15161718192021
22232425262728
2930  

Login