a
This commit is contained in:
@@ -1,2 +1,7 @@
|
||||
package P6;public class A2 {
|
||||
package P6;
|
||||
|
||||
public class A2 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,33 @@
|
||||
package P6;public class Praktikum {
|
||||
package P6;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Praktikum {
|
||||
public static void main(String[] args) {
|
||||
String home = System.getProperty("user.home");
|
||||
String login = System.getProperty("user.name");
|
||||
var time = java.time.LocalDateTime.now();
|
||||
|
||||
Path p = Paths.get(home, "java-text.tmp");
|
||||
try {
|
||||
if (Files.exists(p))
|
||||
Files.delete(p);
|
||||
}catch (IOException ioe){
|
||||
|
||||
}
|
||||
try (var bw = Files.newBufferedWriter(
|
||||
p, StandardOpenOption.APPEND,
|
||||
StandardOpenOption.CREATE)){
|
||||
bw.write(LocalDateTime.now()+"\n");
|
||||
bw.write("Hello "+login+"\n");
|
||||
bw.write("Ende\n");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user