-package jp.co.areaweb.tools.command;
-import java.io.*;
-
-/**
- * ディレクトリのサイズを求める
- *
- * @author kls040
- * @version 3.0
- */
-public class DirSize {
- /**
- * @param args the command line arguments
- */
- public static void main (String args[]) {
- String outputfile;
-
- if (args.length < 1) {
- outputfile = ".";
- }
- else {
- outputfile = args[0];
- }
-
- try {
- System.out.println(DirSize.size(new File(outputfile)) +"\t"+ outputfile);
- }
- catch(Exception e) {
- e.printStackTrace();
- System.out.println(e.toString());
- }
- }
-
- static long size(File file) throws IOException {
- long size = 0L;
- if (file == null) {
- System.out.println("ERR: ディレクトリが見つかりませんでした。");
- return size;
- }
-
- if (file.isDirectory()) {
- File files[] = file.listFiles();
- if (files != null) {
- for (int i=0; i < files.length; i++) {
- size += size(files[i]);
- }
- }
- }
- else {
- size = file.length();
- }
- return size;
- }
-
-}
+package jp.co.areaweb.tools.command;\r
+import java.io.*;\r
+\r
+/**\r
+ * ディレクトリのサイズを求める\r
+ *\r
+ * @author kls040\r
+ * @version 3.0\r
+ */\r
+public class DirSize {\r
+ /**\r
+ * @param args the command line arguments\r
+ */\r
+ public static void main (String args[]) {\r
+ String outputfile;\r
+ \r
+ if (args.length < 1) {\r
+ outputfile = ".";\r
+ }\r
+ else {\r
+ outputfile = args[0];\r
+ }\r
+\r
+ try {\r
+ System.out.println(DirSize.size(new File(outputfile)) +"\t"+ outputfile);\r
+ }\r
+ catch(Exception e) {\r
+ e.printStackTrace();\r
+ System.out.println(e.toString());\r
+ }\r
+ }\r
+ \r
+ static long size(File file) throws IOException {\r
+ long size = 0L;\r
+ if (file == null) {\r
+ System.out.println("ERR: ディレクトリが見つかりませんでした。");\r
+ return size;\r
+ }\r
+ \r
+ if (file.isDirectory()) {\r
+ File files[] = file.listFiles();\r
+ if (files != null) {\r
+ for (int i=0; i < files.length; i++) {\r
+ size += size(files[i]);\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ size = file.length();\r
+ }\r
+ return size;\r
+ }\r
+\r
+}\r