58 lines
1.1 KiB
Java
58 lines
1.1 KiB
Java
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) {
|
|
|
|
}
|
|
|
|
|
|
}
|
|
} |