トップページ > Selenium API(逆引き) > 【Java】createDir

【Java】createDir・・・ディレクトリを作成する

【PR】業界トップクラスの「高単価報酬」「低マージン」を実現!レバテックフリーランス

「createDir」の引数にディレクトリを指定することで、指定したパスにディレクトリを作成することが出来ます。

説明

◆メソッド
  ・public static boolean createDir(java.io.File dir) throws java.io.IOException
◆使用形態
  ・FileHandler.createDir(new File(folder))
◆備考
  ・作成したいディレクトリのフルパスを渡す必要がある
◆関連項目
  ・ディレクトリを削除する
  ・指定したファイルがzipファイルか調べる

サンプル

import java.io.File;

import org.openqa.selenium.io.FileHandler;

public class WebTest{
  public static void main(String[] args){
	try{
	  //New01フォルダをD:\Test1フォルダに作成する
	  FileHandler.createDir(new File("D:\\Test1\\New01"));
	}catch(Exception e){
      e.printStackTrace();
	}
  }
}
※selenium version 4.1.4で動作確認をしています

Fatal error: Uncaught Google_Service_Exception: Error calling GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A138132118&start-date=7daysAgo&end-date=yesterday&metrics=ga%3Apageviews&dimensions=ga%3ApageTitle%2C+ga%3ApagePath&sort=-ga%3Apageviews&max-results=1000: (403) User does not have sufficient permissions for this profile. in /home/users/1/monda-muki/web/seleniumqref.com/google-api-php-client-1-master/src/Google/Http/REST.php:110 Stack trace: #0 /home/users/1/monda-muki/web/seleniumqref.com/google-api-php-client-1-master/src/Google/Http/REST.php(62): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request), Object(Google_Client)) #1 /home/users/1/monda-muki/web/seleniumqref.com/google-api-php-client-1-master/src/Google/Task/Runner.php(174): Google_Http_REST::doExecute(Object(Google_Client), Object(Google_Http_Request)) #2 /home/users/1/monda-muki/web/seleniumqref.com/google-api-php-client-1-master/src/Google/Http/REST.php(46): Google_Task_Runner->run() #3 /home/users/1/monda-muki/web/seleniumqref in /home/users/1/monda-muki/web/seleniumqref.com/google-api-php-client-1-master/src/Google/Http/REST.php on line 110