OSDN Git Service

重複処理の削除
authoryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Mon, 19 Apr 2010 14:43:12 +0000 (14:43 +0000)
committeryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Mon, 19 Apr 2010 14:43:12 +0000 (14:43 +0000)
git-svn-id: http://192.168.11.7/svn/repository/NicoBrowser/branches/dev20100419_filename@313 bdf3b611-c98c-6041-8292-703d9c9adbe7

src/nicobrowser/NamePattern.java
src/nicobrowser/main/Main.java
src/nicobrowser/util/Util.java

index 83ae08a..f434915 100644 (file)
@@ -21,7 +21,9 @@ public class NamePattern {
     /**
      * 保存ファイル名の命名規則.
      * @param pattern 命名パターン.
-     * @param title ファイル名に用いるタイトル文字列. 禁則文字が入っていてはならない.
+     * @param replaceFrom 禁則文字を指定する.
+     * @param replaceTo 禁則文字をこの文字列に置換する.
+     * @param title ファイル名に用いるタイトル文字列.
      */
     public NamePattern(String pattern, String replaceFrom, String replaceTo, String title) {
         this.pattern = pattern;
index e39c480..72e835c 100644 (file)
@@ -193,7 +193,7 @@ public class Main {
                 prevDate = Calendar.getInstance().getTime();
                 File saveDir = new File(config.getSrcSaveDir());
                 NamePattern np = new NamePattern(config.getFileNamePattern(), config.getFileNameReplaceFrom(), config.
-                        getFileNameReplaceTo(), Util.getRegularFileName(c.getTitle()));
+                        getFileNameReplaceTo(), c.getTitle());
                 log.info("ファイルを取得します: " + c.getNicoId() + " " + c.getTitle());
                 try {
                     VideoInfo vi = instance.getVideoInfo(c.getNicoId());
index 070946e..ddf6e77 100644 (file)
@@ -72,28 +72,4 @@ public class Util {
         }
         return userName;
     }
-
-    /**
-     * ファイル名に使用できない文字を置換する.
-     */
-    public static String getRegularFileName(String title) {
-        if (title == null) {
-            return null;
-        }
-
-        StringBuilder str = new StringBuilder();
-        try {
-            for (int i = 0; i < title.length(); i++) {
-                char c = title.charAt(i);
-                if (c == '\\' || c == '/' || c == ':' || c == '*' || c == '?' || c == '"' || c == '<' || c == '>' || c
-                        == '|' || c == '.') {
-                    c = '_';
-                }
-                str.append(c);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return str.toString();
-    }
 }