About 831,000 results
Open links in new tab
  1. java - extracting substring by lines - Stack Overflow

    Aug 10, 2010 · You can split your string into lines using the split method and then index to get the line you want: String story = "This is the first line.\n" + "This is the second line.\n" + "This is the …

  2. Java String substring() Method - GeeksforGeeks

    Apr 11, 2025 · In Java, the substring() method of the String class returns a substring from the given string. This method is most useful when you deal with text manipulation, parsing, or data …

  3. Java String substring() Method - W3Schools

    String myStr = "Hello, World!"; System.out.println(myStr.substring(7, 12)); The substring() method returns a substring from the string. If the end argument is not specified then the substring will …

  4. string - Java: single line substring - Stack Overflow

    Mar 28, 2014 · You can use two substrings, one that gets the String after 2:, and then one that gets the string before the next new line. string = string.substring(string.indexOf("2:") + 2); string …

  5. Java String substring() - Programiz

    The Java substring() method extracts a part of the string (substring) and returns it. Example class Main { public static void main(String[] args) { String str1 = "java is fun"; // extract substring from …

  6. java - Substring by line number - Stack Overflow

    Aug 30, 2012 · You can, however, split the string by \n and then get the required line: String s = "First line\nSecond line\nThird line\nFourth line"; String[] lines = s.split("\n", -1); …

  7. Java String substring () method - Tpoint Tech

    Mar 24, 2025 · One powerful feature that developers often leverage is the substring method. The method allows us to extract a portion of a string, providing flexibility in manipulating and …

  8. Java String Class lines() Method with Examples - GeeksforGeeks

    Feb 3, 2022 · lines() method is a static method which returns out stream of lines extracted from a given multi-line string, separated by line terminators which are as follows: Line terminators …

  9. How to Extract a Specific Line from a Multi-Line String in Java?

    Feb 14, 2024 · This Java program extracts a specific line from a multi-line string by splitting the string into an array of lines. Then it retrieves the line at the specified index. It uses the split() …

  10. Java Substring: An In-depth Guide - Great Learning

    Sep 3, 2024 · In this comprehensive guide, we will delve deeper into the powerful Java substring method, understanding its uses, best practices, and common pitfalls to avoid. By the end, …

Refresh