docker
This commit is contained in:
8
Docker/TP2/Dockerfile
Normal file
8
Docker/TP2/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM eclipse-temurin:17-jdk
|
||||
|
||||
WORKDIR /Ecriture
|
||||
COPY Ecriture.java .
|
||||
|
||||
RUN javac Ecriture.java
|
||||
|
||||
CMD ["java", "Ecriture"]
|
||||
BIN
Docker/TP2/Ecriture.class
Normal file
BIN
Docker/TP2/Ecriture.class
Normal file
Binary file not shown.
48
Docker/TP2/Ecriture.java
Normal file
48
Docker/TP2/Ecriture.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Ecriture {
|
||||
|
||||
|
||||
public static void ecrireFichier() {
|
||||
try {
|
||||
|
||||
BufferedWriter flux = new BufferedWriter(new FileWriter("Texte.txt", true));
|
||||
|
||||
try {
|
||||
|
||||
String aEcrire = "Hello world!";
|
||||
flux.write(aEcrire, 0, aEcrire.length());
|
||||
flux.newLine();
|
||||
|
||||
try {
|
||||
|
||||
flux.close();
|
||||
|
||||
} catch (IOException e3) {
|
||||
System.err.println("Erreur de fermeture.");
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur d'écriture.");
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
System.err.println("Erreur d'ouverture.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
while (true) {
|
||||
Ecriture.ecrireFichier();
|
||||
System.out.println("Fichier modifié.");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e4) {
|
||||
System.err.println("Erreur de timer.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
Docker/TP2/Texte.txt
Normal file
2
Docker/TP2/Texte.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Hello world!
|
||||
Hello world!
|
||||
Reference in New Issue
Block a user