Read string line by line

    0

    1

    Java Public Recipes

    The above code reads the next line of text from the scanner and stores it in line variable.

    import java.util.Scanner;
    
    Scanner scanner = new Scanner(myString);
    while (scanner.hasNextLine()) {
      String line = scanner.nextLine();
      
    }
    scanner.close();
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.