[Solved] How to only print file contents if there are 10 more lines? [closed]
you can do something like this: BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(“path”)); String line = null; int count = 0; while ((reader.readLine()) != null && count < 11) { count++; } if (count > 10) { reader = new BufferedReader(new FileReader(“path”)); while ((line = reader.readLine()) != null) { System.out.println(line); } … Read more