public void init(String userId) {

    // 기존 디렉로리 삭제 후 재생성
    try {
      FileUtils.deleteDirectory(new File(Path.RESULT_DES_DIR + userId));
    } catch (IOException e) {
      LOGGER.error(e.getMessage(), e);
    }

    // DTO 디렉토리 생성
    File dir = new File(Path.RESULT_DES_DIR + userId + Delimiter.VERTICAL_SLUSH + "dto/");
    if (!dir.isDirectory()) {
      // 디렉토리가 존재하지 않는다면 디렉토리 생성
      dir.mkdirs();
    }

    // mapper 디렉토리 생성
    String sqlMapFilePath =
        Path.RESULT_DES_DIR + userId + Delimiter.VERTICAL_SLUSH + "mapper/sqlmap/";
    dir = new File(sqlMapFilePath);
    if (!dir.isDirectory()) {
      // 디렉토리가 존재하지 않는다면 디렉토리 생성
      dir.mkdirs();
    }
  }
示例#2
0
 /**
  * Deletes a file. If file is a directory, delete it and all sub-directories.
  *
  * <p>The difference between File.delete() and this method are:
  *
  * <ul>
  *   <li>A directory to be deleted does not have to be empty.
  *   <li>You get exceptions when a file or directory cannot be deleted. (java.io.File methods
  *       returns a boolean)
  * </ul>
  *
  * @param file file or directory to delete, must not be <code>null</code>
  * @throws NullPointerException if the directory is <code>null</code>
  * @throws FileNotFoundException if the file was not found
  * @throws IOException in case deletion is unsuccessful
  */
 public static void forceDelete(File file) throws IOException {
   if (file.isDirectory()) {
     deleteDirectory(file);
   } else {
     boolean filePresent = file.exists();
     if (!file.delete()) {
       if (!filePresent) {
         throw new FileNotFoundException("File does not exist: " + file);
       }
       String message = "Unable to delete file: " + file;
       throw new IOException(message);
     }
   }
 }