Skip First line with FileReader – Java

Example how to skip first line of any file which you want to read using FileReader in Java

        BufferedReader br = new BufferedReader(new FileReader("./test.csv"));
 
        br.readLine();
        while ((line = br.readLine()) != null) {
            if (!line.isEmpty()) {
                // use comma as separator
                String[] data = line.split(",");
            }
        }

all what we are doing is adding br.readLine(); before while loop this will read first line so it will be skipped in loop.

Leave a Reply

Your email address will not be published. Required fields are marked *