public File returnFile(long fId, String suffix) { File f = Pools.getFileById(home, fId, suffix); if (!f.exists()) try { Files.createNewFile(f); } catch (IOException e) { throw Lang.wrapThrow(e); } return f; }
public synchronized File returnFile(long fId, String suffix) { File re = _F(fId, suffix); if (!re.exists()) try { Files.createNewFile(re); } catch (IOException e) { throw Lang.wrapThrow(e); } return re; }
public synchronized File createFile(String suffix) { File f = _F(current++, suffix); if (current > max) current = 0; if (!f.exists()) try { Files.createNewFile(f); } catch (IOException e) { throw Lang.wrapThrow(e); } return f; }
public File createFile(String suffix) { if (size > 0 && cursor >= size-1) cursor = -1; long id = ++cursor; File re = Pools.getFileById(home, id, suffix); if (!re.exists()) try { Files.createNewFile(re); } catch (IOException e) { throw Lang.wrapThrow(e); } return re; }
/** * 如果文件对象不存在,则创建它 * * @param f * 文件对象 * @return 传入的文件对象,以便为调用者省略一行代码 */ public static File createFileIfNoExists(File f) { if (null == f) return f; if (!f.exists()) try { Files.createNewFile(f); } catch (IOException e) { throw Lang.wrapThrow(e); } if (!f.isFile()) throw Lang.makeThrow("'%s' should be a file!", f); return f; }
/** * 试图生成一个文件对象,如果文件不存在则创建它。 如果给出的 PATH 是相对路径 则会在 CLASSPATH * 中寻找,如果未找到,则会在用户主目录中创建这个文件 * * @param path * 文件路径,可以以 ~ 开头,也可以是 CLASSPATH 下面的路径 * @return 文件对象 * @throws IOException * 创建失败 */ public static File createFileIfNoExists(String path) throws IOException { String thePath = Disks.absolute(path); if (null == thePath) thePath = Disks.normalize(path); File f = new File(thePath); if (!f.exists()) Files.createNewFile(f); if (!f.isFile()) throw Lang.makeThrow("'%s' should be a file!", path); return f; }
return false; if (!target.exists()) if (!createNewFile(target)) return false;
Files.createNewFile(f);
Files.createNewFile(f);
public File returnFile(long fId, String suffix) { File f = Pools.getFileById(home, fId, suffix); if (!f.exists()) try { Files.createNewFile(f); } catch (IOException e) { throw Lang.wrapThrow(e); } return f; }
public synchronized File returnFile(long fId, String suffix) { File re = _F(fId, suffix); if (!re.exists()) try { Files.createNewFile(re); } catch (IOException e) { throw Lang.wrapThrow(e); } return re; }
public synchronized File createFile(String suffix) { File f = _F(current++, suffix); if (current > max) current = 0; if (!f.exists()) try { Files.createNewFile(f); } catch (IOException e) { throw Lang.wrapThrow(e); } return f; }
public File createFile(String suffix) { if (size > 0 && cursor >= size-1) cursor = -1; long id = ++cursor; File re = Pools.getFileById(home, id, suffix); if (!re.exists()) try { Files.createNewFile(re); } catch (IOException e) { throw Lang.wrapThrow(e); } return re; }
/** * 如果文件对象不存在,则创建它 * * @param f * 文件对象 * @return 传入的文件对象,以便为调用者省略一行代码 */ public static File createFileIfNoExists(File f) { if (null == f) return f; if (!f.exists()) try { Files.createNewFile(f); } catch (IOException e) { throw Lang.wrapThrow(e); } if (!f.isFile()) throw Lang.makeThrow("'%s' should be a file!", f); return f; }
/** * 试图生成一个文件对象,如果文件不存在则创建它。 如果给出的 PATH 是相对路径 则会在 CLASSPATH * 中寻找,如果未找到,则会在用户主目录中创建这个文件 * * @param path * 文件路径,可以以 ~ 开头,也可以是 CLASSPATH 下面的路径 * @return 文件对象 * @throws IOException * 创建失败 */ public static File createFileIfNoExists(String path) throws IOException { String thePath = Disks.absolute(path); if (null == thePath) thePath = Disks.normalize(path); File f = new File(thePath); if (!f.exists()) Files.createNewFile(f); if (!f.isFile()) throw Lang.makeThrow("'%s' should be a file!", path); return f; }
return false; if (!target.exists()) if (!createNewFile(target)) return false;
Files.createNewFile(f);
Files.createNewFile(f);