2012-01-04 6 views

答えて

11
boolean success = new java.io.File(System.getProperty("user.home"), "directory_name").mkdirs(); 
+0

再び 'File' –

+3

ルックには' mkdirs'はありません。 http://docs.oracle.com/javase/1.5.0/docs/api/java/io/File.html#mkdirs() – Synesso

+1

マイ・ブレイク。 –

1

System Properties

!すべての情報を集めてまとめました。

public static void main(String[] args) { 
    String myDirectory = "Yash"; // user Folder Name 
    String path = getUsersHomeDir() + File.separator + myDirectory ; 

    if (new File(path).mkdir()) { 
     System.out.println("Directory is created!"); 
    }else{ 
     System.out.println("Failed to create directory!"); 
    } 
    getOSInfo(); 
} 
public static void getOSInfo(){ 
    String os = System.getProperty("os.name"); 
    String osbitVersion = System.getProperty("os.arch"); 
    String jvmbitVersion = System.getProperty("sun.arch.data.model"); 

    System.out.println(os + " : "+osbitVersion+" : "+jvmbitVersion); 
} 
public static String getUsersHomeDir() { 
    String users_home = System.getProperty("user.home"); 
    return users_home.replace("\\", "/"); // to support all platforms. 
} 

は、使用可能なすべてのプロパティを印刷します。

for (Entry<Object, Object> e : System.getProperties().entrySet()) { 
    System.out.println(String.format("%s = %s", e.getKey(), e.getValue())); 
} 
関連する問題