congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Files.makeDir
Code IndexAdd Tabnine to your IDE (free)

How to use
makeDir
method
in
org.nutz.lang.Files

Best Java code snippets using org.nutz.lang.Files.makeDir (Showing top 20 results out of 315)

origin: nutzam/nutz

/**
 * 创建新文件,如果父目录不存在,也一并创建。可接受 null 参数
 * 
 * @param f
 *            文件对象
 * @return false,如果文件已存在。 true 创建成功
 * @throws IOException
 */
public static boolean createNewFile(File f) throws IOException {
  if (null == f || f.exists())
    return false;
  makeDir(f.getParentFile());
  return f.createNewFile();
}
origin: nutzam/nutz

public synchronized File returnDir(long fId) {
  File re = _F(fId, null);
  if (!re.exists())
    Files.makeDir(re);
  return re;
}
origin: nutzam/nutz

public File returnDir(long fId) {
  File f = Pools.getFileById(home, fId, null);
  if (!f.exists())
    Files.makeDir(f);
  return f;
}

origin: nutzam/nutz

public void clear() {
  Files.deleteDir(home);
  Files.makeDir(home);
  cursor = 0;
}
origin: nutzam/nutz

/**
 * 将文件改名
 * 
 * @param src
 *            文件
 * @param newName
 *            新名称
 * @return 改名是否成功
 */
public static boolean rename(File src, String newName) {
  if (src == null || newName == null)
    return false;
  if (src.exists()) {
    File newFile = new File(src.getParent() + "/" + newName);
    if (newFile.exists())
      return false;
    Files.makeDir(newFile.getParentFile());
    return src.renameTo(newFile);
  }
  return false;
}
origin: nutzam/nutz

/**
 * 将文件移动到新的位置
 * 
 * @param src
 *            原始文件
 * @param target
 *            新文件
 * @return 移动是否成功
 * @throws IOException
 */
public static boolean move(File src, File target) throws IOException {
  if (src == null || target == null)
    return false;
  makeDir(target.getParentFile());
  if (src.isDirectory()) {
    src = new File(src.getCanonicalPath() + File.separator);
    target = new File(target.getCanonicalPath() + File.separator);
  }
  return src.renameTo(target);
}
origin: nutzam/nutz

public synchronized File createDir() {
  File f = _F(current++, null);
  if (current > max)
    current = 0;
  if (f.exists())
    Files.clearDir(f);
  else
    Files.makeDir(f);
  return f;
}
origin: nutzam/nutz

/**
 * 传入一个目录对象,如果目录不存在,则创建目录
 * 
 * @param d
 *            文件目录对象
 * @return 文件目录对象,以便调用者省略一行代码
 */
public static File createDirIfNoExists(File d) {
  if (null == d)
    return d;
  if (!d.exists()) {
    if (!Files.makeDir(d)) {
      throw Lang.makeThrow("fail to create '%s', permission deny?", d.getAbsolutePath());
    }
  }
  if (!d.isDirectory())
    throw Lang.makeThrow("'%s' should be a directory!", d);
  return d;
}
origin: nutzam/nutz

/**
 * 拷贝一个目录
 * 
 * @param src
 *            原始目录
 * @param target
 *            新目录
 * @return 是否拷贝成功
 * @throws IOException
 */
public static boolean copyDir(File src, File target) throws IOException {
  if (src == null || target == null || !src.exists())
    return false;
  if (!src.isDirectory())
    throw new IOException(src.getAbsolutePath() + " should be a directory!");
  if (!target.exists())
    if (!makeDir(target))
      return false;
  boolean re = true;
  File[] files = src.listFiles();
  if (null != files) {
    for (File f : files) {
      if (f.isFile())
        re &= copyFile(f, new File(target.getAbsolutePath() + "/" + f.getName()));
      else
        re &= copyDir(f, new File(target.getAbsolutePath() + "/" + f.getName()));
    }
  }
  return re;
}
origin: nutzam/nutz

/**
 * 试图生成一个目录对象,如果文件不存在则创建它。 如果给出的 PATH 是相对路径 则会在 CLASSPATH
 * 中寻找,如果未找到,则会在用户主目录中创建这个目录
 * 
 * @param path
 *            文件路径,可以以 ~ 开头,也可以是 CLASSPATH 下面的路径
 * @return 文件对象
 */
public static File createDirIfNoExists(String path) {
  String thePath = Disks.absolute(path);
  if (null == thePath)
    thePath = Disks.normalize(path);
  File f = new File(thePath);
  if (!f.exists()) {
    boolean flag = Files.makeDir(f);
    if (!flag) {
      Logs.get().warnf("create filepool dir(%s) fail!!", f.getPath());
    }
  }
  if (!f.isDirectory())
    throw Lang.makeThrow("'%s' should be a directory or don't have permission to create it!", path);
  return f;
}
origin: org.nutz/nutz

/**
 * 创建新文件,如果父目录不存在,也一并创建。可接受 null 参数
 * 
 * @param f
 *            文件对象
 * @return false,如果文件已存在。 true 创建成功
 * @throws IOException
 */
public static boolean createNewFile(File f) throws IOException {
  if (null == f || f.exists())
    return false;
  makeDir(f.getParentFile());
  return f.createNewFile();
}
origin: org.nutz/nutz

public void clear() {
  Files.deleteDir(home);
  Files.makeDir(home);
  cursor = 0;
}
origin: org.nutz/nutz

public synchronized File returnDir(long fId) {
  File re = _F(fId, null);
  if (!re.exists())
    Files.makeDir(re);
  return re;
}
origin: org.nutz/nutz

public File returnDir(long fId) {
  File f = Pools.getFileById(home, fId, null);
  if (!f.exists())
    Files.makeDir(f);
  return f;
}

origin: org.nutz/nutz

/**
 * 将文件移动到新的位置
 * 
 * @param src
 *            原始文件
 * @param target
 *            新文件
 * @return 移动是否成功
 * @throws IOException
 */
public static boolean move(File src, File target) throws IOException {
  if (src == null || target == null)
    return false;
  makeDir(target.getParentFile());
  if (src.isDirectory()) {
    src = new File(src.getCanonicalPath() + File.separator);
    target = new File(target.getCanonicalPath() + File.separator);
  }
  return src.renameTo(target);
}
origin: org.nutz/nutz

/**
 * 将文件改名
 * 
 * @param src
 *            文件
 * @param newName
 *            新名称
 * @return 改名是否成功
 */
public static boolean rename(File src, String newName) {
  if (src == null || newName == null)
    return false;
  if (src.exists()) {
    File newFile = new File(src.getParent() + "/" + newName);
    if (newFile.exists())
      return false;
    Files.makeDir(newFile.getParentFile());
    return src.renameTo(newFile);
  }
  return false;
}
origin: org.nutz/nutz

public synchronized File createDir() {
  File f = _F(current++, null);
  if (current > max)
    current = 0;
  if (f.exists())
    Files.clearDir(f);
  else
    Files.makeDir(f);
  return f;
}
origin: org.nutz/nutz

/**
 * 传入一个目录对象,如果目录不存在,则创建目录
 * 
 * @param d
 *            文件目录对象
 * @return 文件目录对象,以便调用者省略一行代码
 */
public static File createDirIfNoExists(File d) {
  if (null == d)
    return d;
  if (!d.exists()) {
    if (!Files.makeDir(d)) {
      throw Lang.makeThrow("fail to create '%s', permission deny?", d.getAbsolutePath());
    }
  }
  if (!d.isDirectory())
    throw Lang.makeThrow("'%s' should be a directory!", d);
  return d;
}
origin: Rekoe/rk_svnadmin

  @SuppressWarnings("deprecation")
  public File upload(TempFile tempFile, String savePath) throws Exception {
    Files.makeDir(new File(savePath));
    File saveFile = new File(savePath);
    Files.move(tempFile.getFile(), saveFile);
    if (log.isDebugEnabled()) {
      log.debugf("save path[%s]", savePath);
    }
    return saveFile;
  }
}
origin: Rekoe/rk_svnadmin

@SuppressWarnings("deprecation")
public File upload(TempFile tempFile) throws Exception {
  String savePath = conf.get("xlsPath") + "/" + tempFile.getSubmittedFileName();
  Files.makeDir(new File(conf.get("xlsPath")));
  File saveFile = new File(savePath);
  Files.move(tempFile.getFile(), saveFile);
  if (log.isDebugEnabled()) {
    log.debugf("save path[%s]", savePath);
  }
  return saveFile;
}
org.nutz.langFilesmakeDir

Javadoc

创建新目录,如果父目录不存在,也一并创建。可接受 null 参数

Popular methods of Files

  • findFile
    从 CLASSPATH 下或从指定的本机器路径下寻找一个文件
  • createDirIfNoExists
    试图生成一个目录对象,如果文件不存在则创建它。 如果给出的 PATH 是相对路径 则会在 CLASSPATH 中寻找,如果未找到,则会在用户主目录中创建这个目录
  • createFileIfNoExists
    试图生成一个文件对象,如果文件不存在则创建它。 如果给出的 PATH 是相对路径 则会在 CLASSPATH 中寻找,如果未找到,则会在用户主目录中创建这个文件
  • getSuffixName
    获取文件后缀名,不包括 '.',如 'abc.gif',',则返回 'gif'
  • readBytes
    读取文件全部字节,并关闭文件
  • renameSuffix
    将文件路径后缀改名,从而生成一个新的文件路径。
  • write
    将内容写到一个文件内,内容对象可以是: * InputStream - 按二进制方式写入 * byte[] - 按二进制方式写入 * Reader - 按 UTF-8 方式写入 * 其他对象被
  • cleanAllFolderInSubFolderes
    将一个目录下的特殊名称的目录彻底删除,比如 '.svn' 或者 '.cvs'
  • deleteFile
    删除一个文件
  • findFileAsStream
    获取输出流
  • getName
  • read
    读取 UTF-8 文件全部内容
  • getName,
  • read,
  • checkFile,
  • clearDir,
  • copy,
  • copyDir,
  • copyFile,
  • copyOnWrite,
  • createNewFile

Popular in Java

  • Parsing JSON documents to java classes using gson
  • putExtra (Intent)
  • compareTo (BigDecimal)
  • runOnUiThread (Activity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Runner (org.openjdk.jmh.runner)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now