Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class GloballyReplaceText {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
|
||||
String s = new String(Files.readAllBytes(Paths.get(fn)));
|
||||
s = s.replace("Goodbye London!", "Hello New York!");
|
||||
try (FileWriter fw = new FileWriter(fn)) {
|
||||
fw.write(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
for (String fn : List.of("file1.txt","file2.txt")) {
|
||||
Path path = Path.of(fn);
|
||||
Files.writeString(path,
|
||||
Files.readString(path).replace("Goodbye London!", "Hello New York!"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue