TP 15/16
This commit is contained in:
BIN
APL2.1/TP16/Conversion/Conversion.class
Normal file
BIN
APL2.1/TP16/Conversion/Conversion.class
Normal file
Binary file not shown.
53
APL2.1/TP16/Conversion/Conversion.java
Normal file
53
APL2.1/TP16/Conversion/Conversion.java
Normal file
@@ -0,0 +1,53 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1
APL2.1/TP16/Conversion/base.html
Normal file
1
APL2.1/TP16/Conversion/base.html
Normal file
@@ -0,0 +1 @@
|
||||
<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"><title>OwO</title></head><body><p>TOREPLACE</p></body></html>
|
9
APL2.1/TP16/Conversion/funny.txt
Normal file
9
APL2.1/TP16/Conversion/funny.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
jiGJIOPAEJIOGOJIEAGJIOAEIO
|
||||
ZFIAJPIFPJIAZJPF
|
||||
|
||||
AQG
|
||||
AQGAZ
|
||||
GAZ
|
||||
GAZAZ
|
||||
GAZAZ
|
||||
GAZ
|
1
APL2.1/TP16/Conversion/funny.txt.html
Normal file
1
APL2.1/TP16/Conversion/funny.txt.html
Normal file
@@ -0,0 +1 @@
|
||||
<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"><title>OwO</title></head><body><p>jiGJIOPAEJIOGOJIEAGJIOAEIO<br>ZFIAJPIFPJIAZJPF<br><br>AQG<br>AQGAZ<br>GAZ<br>GAZAZ<br>GAZAZ<br>GAZ</p></body></html>
|
Reference in New Issue
Block a user