User:Mwn3d/Java 7 stuff
Try with resources: <lang java5>try(BufferedWriter output = new BufferedWriter(new FileWriter("fileName.txt" , true));
BufferedReader input = new BufferedReader(new FileReader("otherFile.txt"))/*;other streams if you want*/){ output.write("some text" + input.readLine());
}catch(IOException e){
System.err.println("I'm sorry, Dave, but I can't let you do that");
}</lang> The readers and writers are closed automatically. Exceptions can be caught for initialization errors, writing/reading errors, and closing errors. This also checks for nulls when closing, so it removes the need for nested try-catch-finally blocks when using multiple readers/writers.
Diamond type inference:
<lang java5>Map <String, List<? extends Number>> numbers = new HashMap<>();</lang>
Infers types to place inside <>
. Uses the most specific types that it can based on the types on the left (String
and Number
for this example), rather than just copying text from the left to the right.
Divide and conquer methods for multicore CPUs coming once I understand it