Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by Jesus_de_la_Casa ( 6 years ago )
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("Debes introducir la ruta del archivo");
} else {
String text = readLines();
saveText(text, args[0]);
}
System.exit(0);
}
private static String readLines() {
String text = new Date().toString() + "\n";
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
String line = sc.nextLine();
if (line.equals("close"))
break;
text = text + "\n" + line;
}
sc.close();
return text;
}
private static void saveText(String text, String file) {
System.out.println(text);
try (PrintWriter writer = new PrintWriter(file)) {
writer.write(text);
writer.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Revise this Paste