New line in Java for HTML and Changing HTML file
This commit is contained in:
parent
b9b4cec7ae
commit
6dd09ae35d
@ -7,6 +7,7 @@ public class AddingNewLineToString {
|
||||
String line2 = "Humpty Dumpty had a great fall.";
|
||||
String para = "";
|
||||
|
||||
System.out.println("***New Line in a String in Java***");
|
||||
//1. Using "\n"
|
||||
System.out.println("1. Using \\n");
|
||||
para = line1 + "\n" + line2;
|
||||
@ -38,18 +39,31 @@ public class AddingNewLineToString {
|
||||
para = line1 + System.getProperty("line.separator") + line2;
|
||||
System.out.println(para);
|
||||
|
||||
//Line break for HTML using <br>
|
||||
System.out.println("Line break for HTML using <br>");
|
||||
System.out.println("***HTML to rendered in a browser***");
|
||||
//1. Line break for HTML using <br>
|
||||
System.out.println("1. Line break for HTML using <br>");
|
||||
para = line1 + "<br>" + line2;
|
||||
System.out.println(para);
|
||||
|
||||
//Line break for HTML when string is in <textarea> tag
|
||||
//2. Line break for HTML using “ ”
|
||||
System.out.println("2. Line break for HTML using ");
|
||||
para = line1 + " " + line2;
|
||||
System.out.println(para);
|
||||
|
||||
//3. Line break for HTML using “ ”
|
||||
System.out.println("3. Line break for HTML using ");
|
||||
para = line1 + " " + line2;
|
||||
System.out.println(para);
|
||||
|
||||
//Line break for HTML when string is in <pre> tag
|
||||
para = line1+" "+line2;
|
||||
//4. Line break for HTML using “
 ;”
|
||||
System.out.println("4. Line break for HTML using ");
|
||||
para = line1 + " " + line2;
|
||||
para = line1+"<br>"+line2;
|
||||
System.out.println(para);
|
||||
|
||||
//5. Line break for HTML using \n”
|
||||
System.out.println("5. Line break for HTML using \\n");
|
||||
para = line1 + "\n" + line2;
|
||||
System.out.println(para);
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,31 @@
|
||||
<html>
|
||||
<body>
|
||||
Humpty Dumpty sat on a wall.<br>Humpty Dumpty had a great fall.
|
||||
Humpty Dumpty sat on a wall.<br>Humpty Dumpty had a great fall.<br>
|
||||
Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall.<br>
|
||||
Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall.<br>
|
||||
Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall.<br>
|
||||
Humpty Dumpty sat on a wall.
|
||||
Humpty Dumpty had a great fall.
|
||||
<br>
|
||||
<textarea>Hello<br>Baeldung</textarea>
|
||||
<textarea>Hello Baeldung</textarea>
|
||||
<textarea>Hello Baeldung</textarea>
|
||||
<pre>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall</pre>
|
||||
<pre>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall</pre>
|
||||
<pre>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall</pre>
|
||||
<textarea>Hello Baeldung</textarea>
|
||||
<textarea>Hello.
|
||||
Baeldung</textarea>
|
||||
<br>
|
||||
<pre>Humpty Dumpty sat on a wall.<br>Humpty Dumpty had a great fall.</pre>
|
||||
<pre>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall.</pre>
|
||||
<pre>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall.</pre>
|
||||
<pre>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall.</pre>
|
||||
<pre>Humpty Dumpty sat on a wall.
|
||||
Humpty Dumpty had a great fall</pre>
|
||||
<br>
|
||||
<p>Humpty Dumpty sat on a wall.<br>Humpty Dumpty had a great fall</p>
|
||||
<p>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall</p>
|
||||
<p>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall</p>
|
||||
<p>Humpty Dumpty sat on a wall. Humpty Dumpty had a great fall</p>
|
||||
<p>Humpty Dumpty sat on a wall.
|
||||
Humpty Dumpty had a great fall</p>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user