Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Main {
- public Main() {
- File directory = new File("C:/Documents and Settings/Administrator/Desktop/Deadlypkers/Data/characters/");
- String[] allFiles = directory.list();
- if (allFiles == null) {
- System.out.println("No such directory");//brkownz
- return;
- }
- for (int file = 0; file < allFiles.length; file++) {
- File f = new File("C:/Documents and Settings/Administrator/Desktop/Deadlypkers/Data/characters/"+allFiles[file]+"/");
- System.out.println(f);
- FileInputStream fs = null;
- InputStreamReader in = null;
- BufferedReader br = null;
- String textinLine;
- StringBuffer sb = new StringBuffer();
- String newLine = System.getProperty("line.separator");
- try {
- fs = new FileInputStream(f);
- in = new InputStreamReader(fs);
- br = new BufferedReader(in);
- while(true) {
- textinLine=br.readLine();
- if(textinLine==null)
- break;
- sb.append(textinLine);
- sb.append(newLine);
- }
- int textBeginFishing = sb.indexOf("character-skill = 7");
- int textEndFishing = sb.indexOf("character-skill = 8");
- if (textBeginFishing == -1 || textEndFishing == -1) {
- System.out.println("Skipped the file: "+allFiles[file]);
- fs.close();
- in.close();
- br.close();
- continue;
- }
- String toChangeFishing = "character-skill = 7 1 0"+newLine;
- sb.replace(textBeginFishing, textEndFishing, toChangeFishing);
- int textBeginCooking = sb.indexOf("character-skill = 10");
- int textEndCooking = sb.indexOf("character-skill = 11");
- String toChangeCooking = "character-skill = 10 1 0"+newLine;
- sb.replace(textBeginCooking, textEndCooking, toChangeCooking);
- fs.close();
- in.close();
- br.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- FileWriter fstream = new FileWriter(f);
- BufferedWriter outobj = new BufferedWriter(fstream);
- outobj.write(sb.toString());
- outobj.close();
- } catch (Exception e) {
- System.err.println("Error: " + e.getMessage());
- }
- }
- }
- public static void main(String[] args) {
- new Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement