]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/Common.java
Modify Critic
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / Common.java
index 3468a43cebb3c26fffcd260ddbae8834f8ec99ed..d3d781f32213b89d81c635c338ad874866a12a44 100644 (file)
@@ -29,6 +29,14 @@ public class Common {
                return wholefile.toString();\r
        }\r
 \r
+       public static void string2file(String content, String filename) throws Exception {\r
+               ensureDir(filename);\r
+               PrintWriter outfile = new PrintWriter(new BufferedWriter(new FileWriter(filename)));\r
+               outfile.append(content);\r
+               outfile.flush();\r
+               outfile.close();\r
+       }\r
+\r
        public static void ensureDir(String objFileWhole) {\r
                File tempdir;\r
                Matcher mtrseparate = ptnseparate.matcher(objFileWhole);\r
@@ -38,14 +46,6 @@ public class Common {
                }\r
        }\r
        \r
-       public static void string2file(String content, String filename) throws Exception {\r
-               ensureDir(filename);\r
-               PrintWriter outfile = new PrintWriter(new BufferedWriter(new FileWriter(filename)));\r
-               outfile.append(content);\r
-               outfile.flush();\r
-               outfile.close();\r
-       }\r
-       \r
        public static HashSet<String> dirScan(String path) {                    // use HashSet, persue speed rather than space\r
                HashSet<String> filelist = new HashSet<String>();\r
                String[] list = new File(path).list();\r
@@ -63,6 +63,14 @@ public class Common {
                return filelist;\r
        }\r
 \r
+       public static String replaceAll(String line, Pattern ptn, String des) {\r
+               Matcher mtr = ptn.matcher(line);\r
+               if (mtr.find()) {\r
+                        return mtr.replaceAll(des);\r
+               }\r
+               return line;\r
+       }\r
+       \r
        public static String dirCopy_(String src) throws Exception {\r
                Matcher mtrseparate = Common.ptnseparate.matcher(src);\r
                if (mtrseparate.find()) {\r