3 import java.io.BufferedReader;
4 import java.io.PrintWriter;
5 import java.io.FileReader;
6 import java.io.FileWriter;
7 import java.util.Collection;
8 import java.util.HashMap;
10 import java.util.Iterator;
19 public static void main(String[] args)
22 final String toVersion = args[0];
23 final String fileName = args[1];
24 File temp = File.createTempFile(
"temp",
".xml");
27 Map<String, String> rep =
new HashMap<String, String>();
28 if (toVersion.equalsIgnoreCase(
"1.1")) {
29 rep.put(
"startTime",
"beginTime");
30 rep.put(
"finalTime",
"endTime");
31 rep.put(
"ptolemy.actor.lib.MonitorValue",
"ptolemy.actor.lib.gui.MonitorValue");
34 throw new Exception(
"Version number '" + toVersion +
"' is not valid.");
36 FileReader fr =
new FileReader(fileName);
37 BufferedReader reader =
new BufferedReader(fr);
38 FileWriter fw =
new FileWriter(temp);
39 PrintWriter writer =
new PrintWriter(fw);
41 Collection
c = rep.values();
42 while ((line = reader.readLine()) != null){
43 for (Map.Entry<String, String> entry : rep.entrySet()){
44 line =
new String(line.replaceAll((String)(entry.getKey()), (String)(entry.getValue())));
52 temp.renameTo(
new File(fileName));
static void main(String[] args)
Replace string in files.
FSCHANGE is a Mathworks internal function that is used for troubleshooting purposes It takes the name of a directory as an input and forces the MATLAB path manager to recheck the contents of the directory to check for windows have Windows c