APL/APL2.1/TP16/Conversion/Conversion.java
2022-05-24 17:28:29 +02:00

54 lines
1.5 KiB
Java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Conversion {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new FileReader(args[0]))) {
String fullContent = "";
String htmlContent = "";
{
int i = 0;
boolean canRead = true;
while (canRead) {
String content = br.readLine();
if (content != null) {
if (i == 0) {
fullContent += content;
} else {
fullContent += "<br>" + content;
}
i++;
} else canRead = false;
}
}
System.out.println(fullContent);
br.close();
try (BufferedReader br2 = new BufferedReader(new FileReader("base.html"))) {
htmlContent = br2.readLine();
br2.close();
} catch (Exception e) {
}
htmlContent = htmlContent.replaceAll("TOREPLACE", fullContent);
System.out.println(htmlContent);
try (BufferedWriter bw = new BufferedWriter(new FileWriter(args[0] + ".html"))) {
bw.write(htmlContent);
bw.close();
} catch (IOException e) {
}
} catch (IOException e) {
}
}
}