Java 7 [new] -

// Java 7 try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) br.readLine(); catch (IOException e) e.printStackTrace();

Automatically closes resources implementing AutoCloseable . java 7

Project Coin was a collection of "nice-to-have" features designed to reduce boilerplate code and make the language more expressive. // Java 7 try (BufferedReader br = new

Path path = Paths.get("/home/user/data.txt"); // Create/delete Files.createDirectories(path.getParent()); Files.deleteIfExists(path); // Copy Files.copy(Paths.get("source.txt"), Paths.get("dest.txt"), StandardCopyOption.REPLACE_EXISTING); // Read all lines (small files) List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8); // Walk a directory try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("/home"))) for (Path entry : stream) System.out.println(entry.getFileName()); catch (IOException e) e.printStackTrace()

This was a game-changer for resource management. It automatically closes resources (like files or database connections) that implement AutoCloseable , eliminating the need for messy finally blocks.

int million = 1_000_000; long creditCard = 1234_5678_9012_3456L;