TP3
This commit is contained in:
BIN
DEV2.1/TP14/01_Conversion/Main.class
Normal file
BIN
DEV2.1/TP14/01_Conversion/Main.class
Normal file
Binary file not shown.
58
DEV2.1/TP14/01_Conversion/Main.java
Normal file
58
DEV2.1/TP14/01_Conversion/Main.java
Normal file
@@ -0,0 +1,58 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
String chaine = "";
|
||||
// Lecture
|
||||
try {
|
||||
BufferedReader lecture = new BufferedReader(new FileReader(args[0]));
|
||||
|
||||
try {
|
||||
String texte = lecture.readLine();
|
||||
while (texte != null) {
|
||||
chaine += texte;
|
||||
chaine += "\n";
|
||||
texte = lecture.readLine();
|
||||
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur de lecture.");
|
||||
}
|
||||
|
||||
try {
|
||||
lecture.close();
|
||||
} catch(IOException e3) {
|
||||
System.err.println("Erreur de fermeture.");
|
||||
}
|
||||
} catch(IOException e) {
|
||||
System.err.println("Erreur d'ouverture");
|
||||
}
|
||||
|
||||
//Ecriture
|
||||
|
||||
try {
|
||||
BufferedWriter ecriture = new BufferedWriter(new FileWriter(args[0].split("[.]")[0] + ".html"));
|
||||
|
||||
String html = "<!DOCTYPE html>\n <html>\n <body><p>";
|
||||
String finHtml = "</p>\n </body>\n </html>";
|
||||
try {
|
||||
ecriture.write(html);
|
||||
ecriture.write(chaine);
|
||||
ecriture.write(finHtml);
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
ecriture.close();
|
||||
} catch (IOException e3) {
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
17
DEV2.1/TP14/01_Conversion/texte.html
Normal file
17
DEV2.1/TP14/01_Conversion/texte.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body><p>Mathias
|
||||
Le
|
||||
Goat
|
||||
De
|
||||
L'IUT
|
||||
De
|
||||
Fontainebleau
|
||||
Je
|
||||
Lui
|
||||
Lèche
|
||||
Les
|
||||
Pieds
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
12
DEV2.1/TP14/01_Conversion/texte.txt
Normal file
12
DEV2.1/TP14/01_Conversion/texte.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Mathias
|
||||
Le
|
||||
Goat
|
||||
De
|
||||
L'IUT
|
||||
De
|
||||
Fontainebleau
|
||||
Je
|
||||
Lui
|
||||
Lèche
|
||||
Les
|
||||
Pieds
|
Reference in New Issue
Block a user