// Code to read data from file try { BufferedReader br = new BufferedReader(new FileReader("file.txt")); String line = br.readLine(); while (line != null) { System.out.println(line); line = br.readLine(); } br.close(); } catch (IOException e) { e.printStackTrace(); } // Code to write data to file try { BufferedWriter bw = new BufferedWriter(new FileWriter("file.txt")); bw.write("Writing to file using Java"); bw.close(); } catch (IOException e) { e.printStackTrace(); }
// Code to find square root of a number double num = 25; double sqrt = Math.sqrt(num); System.out.println("The square root of " + num + " is " + sqrt);Package Library: java.lang.Math