try { FileReader fr = new FileReader("input.txt"); BufferedReader br = new BufferedReader(fr); String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); }
try { FileWriter fw = new FileWriter("output.txt"); BufferedWriter bw = new BufferedWriter(fw); bw.write("Hello, world!"); bw.newLine(); bw.write("How are you?"); bw.close(); } catch (IOException e) { e.printStackTrace(); }
int a = 5; int b = 3; int min = Math.min(a, b); System.out.println(min); // Output: 3This example uses Math.min to find the smaller of two integers, storing the result in a variable named "min" and then printing it to the console.