Answers for "java add new line to string"

9

java string next line

// its \r\n
String a = "Hello, "
String b = "there!"
System.out.println(a+b);//returns Hello, there
System.out.println(a+"\r\n"+b);//returns Hello, 
//there! //it will be on the next line!
Posted by: Guest on July-08-2020
0

how to convert line into string java

File file = new File(fileName);
Scanner input = new Scanner(file);
List<String> list = new ArrayList<String>();

while (input.hasNextLine()) {
    list.add(input.nextLine());
}

//adds each line of a text file into an ArrayList
Posted by: Guest on August-24-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language