Guest User

Untitled

a guest
Aug 10th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Replace \n in BufferedWriter.write()?
  2. String input = "Name: adfasd n AN: asdfasdf n";
  3. Writer textOutput = null;
  4. File file = new File("write.txt");
  5. textOutput = new BufferedWriter(new FileWriter(file));
  6. textOutput.write( input );
  7. textOutput.close();
  8.  
  9. String text = "Line 1 \n Line2";
  10. System.out.println(text);
  11. System.out.println(text.replace("\n", "n"));
  12.  
  13. public void test() throws IOException {
  14. BufferedWriter writer = new BufferedWriter(new FileWriter("/someDir/test.txt"));
  15. writer.write("HellonWorld");
  16. writer.close();
  17. }
  18.  
  19. Hello
  20. World
Add Comment
Please, Sign In to add comment