joseleonweb

Untitled

Mar 1st, 2021
414
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2.  
  3. public class KtoD {
  4.  
  5.     public static void main(String[] args) {
  6.         String str;
  7.         BufferedReader br =
  8.                 new BufferedReader(
  9.                         new InputStreamReader(System.in));
  10.         System.out.println("Enter text ('stop' to quit).");
  11.        
  12.         try (FileWriter fw = new FileWriter("test.txt"))
  13.         {
  14.             do {
  15.                 System.out.print(": ");
  16.                 str = br.readLine();
  17.                
  18.                 if(str.compareTo("stop") == 0) break;
  19.                
  20.                 str = str + "\r\n"; // add newline
  21.                 fw.write(str);
  22.             } while(str.compareTo("stop") != 0);
  23.         } catch(IOException exc) {
  24.             System.out.println("I/O Error: " + exc);
  25.         }
  26.     }
  27. }
  28.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×