Java Scanner Usage removeFirstNLines(String text, int n)

Here you can find the source of removeFirstNLines(String text, int n)

Description

remove First N Lines

License

Open Source License

Declaration

public static String removeFirstNLines(String text, int n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Scanner;

public class Main {
    public static String removeFirstNLines(String text, int n) {
        Scanner scanner = new Scanner(text);
        int i = 0;
        while (scanner.hasNextLine() && i < n) {
            scanner.nextLine();//from   w w w . ja v a 2 s  . c  o  m
            i++;
        }

        String result = "";
        while (scanner.hasNextLine()) {
            result += scanner.nextLine() + "\n";
        }

        scanner.close();
        return result;
    }
}

Related

  1. pathTokenList(String path)
  2. pressEnterToContinue()
  3. processLine(String aLine)
  4. queryMenu(Scanner in, String msg, LinkedList options)
  5. queryStr(Scanner in, String msg)
  6. removeIndexes(String xpath)
  7. removeNLinesForwardsFromStringMatch(String text, String match, int n)
  8. selectProject(List projectList)
  9. splitLines(String string)