title: How can I insert text before and after each line of a text file?
body: <p>Below is my code that reads in a file, and then writes its contents to a new file. What I need to do is add in text between each line of text from the old file and put that in the new file. In this code, the file is read as a whole, so how do I change it to go through line by line and add text between each?</p>
  
  <pre><code>import java.io.IOException;
  import java.nio.file.Files;
  import java.nio.file.Paths;
  import java.nio.file.StandardOpenOption;
  import java.util.List;
  
  public class Webpage {
    public static String readTextFile(String fileName) throws IOException {
      String content = new String(Files.readAllBytes(Paths.get(fileName)));
      return content;
    }
  
    public static List&lt;String&gt; readTextFileByLines(String fileName)throws IOException {
      List&lt;String&gt; lines = Files.readAllLines(Paths.get(fileName));
      return lines;
    }
  
    public static void writeToTextFile(String fileName, String content)throws IOException {
      Files.write(Paths.get(fileName), content.getBytes(), StandardOpenOption.CREATE);
    }
  
  } 
  </code></pre>