#1 bitEe.Eu
Ak máš Javu 7 tak skús nejak takto
try {
String string = "mp3";
String newString = "mp3: YES";
Path file = Paths.get("config");
if (!Files.exists(file)) {
System.err.println("Subor " + file.getFileName() + " neexistuje");
return;
}
List<String> lines = Files.readAllLines(file, Charset.defaultCharset());
Files.deleteIfExists(file);
for (String line : lines) {
if (line.contains(string)) {
lines.set(lines.lastIndexOf(line), newString);
}
}
Files.deleteIfExists(file);
Files.createFile(file);
for (String line : lines) {
line += System.getProperty("line.separator");
Files.write(file, line.getBytes(), StandardOpenOption.APPEND);
}
} catch (IOException ex) {
System.err.println("Chyba: " + ex.getMessage());
}