Here you can find the source of getNextLine(final Scanner scanner)
Parameter | Description |
---|---|
scanner | a parameter |
public static String getNextLine(final Scanner scanner)
//package com.java2s; //License from project: Open Source License import java.util.Scanner; public class Main { /**/* ww w. j av a 2s . c o m*/ * Skips comment lines * * @param scanner * @return comment free line */ public static String getNextLine(final Scanner scanner) { while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); if (line.startsWith("//")) { continue; // Its single comment line, skip } if (line.startsWith("/*")) { // multi line comment String skipLine = line; while (scanner.hasNextLine() && !skipLine.contains("*/")) { // skip until close tag skipLine = scanner.nextLine(); } // in case there is data after comment close tag line = skipLine.substring(skipLine.indexOf("*/") + 2); if (line.isEmpty()) { continue; } } return line; } return ""; } }