LoginSignup
4
1

More than 5 years have passed since last update.

java ディレクトリ作成

Last updated at Posted at 2018-06-28

ディレクトリの作成にはFileクラスのmkdirメソッドを使用します

public class fileClass{
    public fileClass() throws IOException{

        File dir = new File("/Users/Shared/java/");

        //mkdirを使用してディレクトリを作成する
        dir.mkdir();
    }
}

上記のサンプルコードではFileクラスのインスタンスに絶対パスでディレクトリを作成し、mkdirメソッドで作成しています。

ファイルを作成する際、すでに作成済みでもさらに作成されることはないです。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1