| 
 | 1 | +# SpringBootMultiLineString  | 
 | 2 | +Spring Boot MultiLine string example  | 
 | 3 | + | 
 | 4 | + @SpringBootApplication  | 
 | 5 | + public class Main implements CommandLineRunner {  | 
 | 6 | + | 
 | 7 | +  public static void main(String[] args) {  | 
 | 8 | + | 
 | 9 | +  SpringApplication.run(Main.class, args);  | 
 | 10 | +  System.out.println("I am in");  | 
 | 11 | + | 
 | 12 | +  }  | 
 | 13 | + | 
 | 14 | +  public void run(String... args) throws Exception {  | 
 | 15 | + | 
 | 16 | +  //Creating string reporte  | 
 | 17 | +   | 
 | 18 | +  String reporte = "";  | 
 | 19 | +  for (int i = 0; i < 10; i++) {  | 
 | 20 | + | 
 | 21 | +  reporte = reporte +"Line"+i+ "\n";// Line1\nLine2\n.......  | 
 | 22 | +  }  | 
 | 23 | +  //Creating file.txt saving the string and defining as multiline  | 
 | 24 | +   | 
 | 25 | +  FileWriter fileWriter = new FileWriter("file.txt", true);  | 
 | 26 | +  BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);  | 
 | 27 | +  bufferedWriter.write(reporte + "\n");  | 
 | 28 | +  bufferedWriter.flush();  | 
 | 29 | +  bufferedWriter.close();  | 
 | 30 | +  fileWriter.close();  | 
 | 31 | + | 
 | 32 | +  }  | 
 | 33 | + }  | 
0 commit comments