Skip to content

Instantly share code, notes, and snippets.

@Sergaav
Last active August 29, 2015 14:18
Show Gist options
  • Save Sergaav/6721426403becfed7f27 to your computer and use it in GitHub Desktop.
Save Sergaav/6721426403becfed7f27 to your computer and use it in GitHub Desktop.
package com.gmail.sergaav.dz7_1;
import java.io.*;
import java.util.Scanner;
public class dz7_1 {
public static void main(String[] args) throws FileNotFoundException {
File ff = new File("file.txt");
try {
if (!ff.exists()) {
ff.createNewFile();
}
} catch (IOException e) {
System.out.println(e);
}
Scanner sc = new Scanner(System.in);
PrintStream writer = new PrintStream(ff);
for (;;){
String data = sc.nextLine();
writer.printf(data+"\n", ff);
writer.println();
if (data.equals("")){
break;
}
}
sc.close();
writer.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment