iamaamir

Whole user input to a File

Aug 3rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. public class Test {
  2.     public static void main(String[] args) {
  3.         System.out.println("Enter your message");
  4.         String userInput = new Scanner(System.in).nextLine();
  5.         try (PrintWriter out = new PrintWriter("test.txt")) {
  6.             out.println(userInput);
  7.         } catch (FileNotFoundException ex) {
  8.         }
  9.     }
  10. }
Add Comment
Please, Sign In to add comment