Codota Logo
Files
Code IndexAdd Codota to your IDE (free)

How to use
Files
in
org.nutz.lang

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: nutzam/nutz

/**
 * 对一个图像进行旋转
 * 
 * @param srcPath
 *            原图像文件路径
 * @param taPath
 *            转换后的图像文件路径
 * @param degree
 *            旋转角度, 90 为顺时针九十度, -90 为逆时针九十度
 * @return 旋转后得图像对象
 */
public static BufferedImage rotate(String srcPath, String taPath, int degree)
    throws IOException {
  File srcIm = Files.findFile(srcPath);
  if (null == srcIm)
    throw Lang.makeThrow("Fail to find image file '%s'!", srcPath);
  File taIm = Files.createFileIfNoExists(taPath);
  return rotate(srcIm, taIm, degree);
}
origin: nutzam/nutz

public UU32FilePool(String path) {
  this.root = Files.createDirIfNoExists(path);
}
origin: nutzam/nutz

/**
 * @see #getSuffixName(String)
 */
public static String getSuffixName(File f) {
  if (null == f)
    return null;
  return getSuffixName(f.getAbsolutePath());
}
origin: nutzam/nutz

public void clear() {
  Files.deleteDir(root);
  this.root = Files.createDirIfNoExists(root);
}
 
origin: nutzam/nutz

/**
 * 读取文件全部字节,并关闭文件
 * 
 * @param path
 *            文件路径
 * @return 文件的字节内容
 */
public static byte[] readBytes(String path) {
  File f = Files.findFile(path);
  if (null == f)
    throw Lang.makeThrow("Can not find file '%s'", path);
  return readBytes(f);
}
origin: nutzam/nutz

/**
 * 读取 UTF-8 文件全部内容
 * 
 * @param path
 *            文件路径
 * @return 文件内容
 */
public static String read(String path) {
  File f = Files.findFile(path);
  if (null == f)
    throw Lang.makeThrow("Can not find file '%s'", path);
  return read(f);
}
origin: nutzam/nutz

@Override
public File cast(String src, Class<?> toType, String... args) throws FailToCastObjectException {
  return Files.findFile(src);
}
origin: nutzam/nutz

/**
 * 将内容写到一个文件内,内容对象可以是:
 * <ul>
 * <li>InputStream - 按二进制方式写入
 * <li>byte[] - 按二进制方式写入
 * <li>Reader - 按 UTF-8 方式写入
 * <li>其他对象被 toString() 后按照 UTF-8 方式写入
 * </ul>
 * 
 * @param path
 *            文件路径,如果不存在,则创建
 * @param obj
 *            内容对象
 */
public static void write(String path, Object obj) {
  if (null == path || null == obj)
    return;
  try {
    write(Files.createFileIfNoExists(path), obj);
  }
  catch (IOException e) {
    throw Lang.wrapThrow(e);
  }
}
origin: nutzam/nutz

public void truncate(long len) throws SQLException {
  Files.write(file, new Byte[]{});
}
origin: nutzam/nutz

/**
 * 根据一个文件路径建立一个输入流
 * 
 * @param path
 *            文件路径
 * @return 输入流
 */
public static InputStream fileIn(String path) {
  InputStream ins = Files.findFileAsStream(path);
  if (null == ins) {
    File f = Files.findFile(path);
    if (null != f)
      try {
        ins = Streams._input(f);
      }
      catch (IOException e) {}
  }
  if (null == ins) {
    // TODO 考虑一下,应该抛异常呢?还是返回null呢?
    throw new RuntimeException(new FileNotFoundException(path));
    // return null;
  }
  return buff(ins);
}
origin: nutzam/nutz

public File removeDir(long fId) {
  File f = Pools.getFileById(home, fId, null);
  if (f.isDirectory()) {
    Files.deleteDir(f);
  } else {
    Files.deleteFile(f);
  }
  return f;
}
origin: nutzam/nutz

/**
 * 将文件后缀改名,从而生成一个新的文件对象。但是并不在磁盘上创建它
 * 
 * @param f
 *            文件
 * @param suffix
 *            新后缀, 比如 ".gif" 或者 ".jpg"
 * @return 新文件对象
 */
public static File renameSuffix(File f, String suffix) {
  if (null == f || null == suffix || suffix.length() == 0)
    return f;
  return new File(renameSuffix(f.getAbsolutePath(), suffix));
}
origin: nutzam/nutz-web

public void clear() {
  key = null;
  File f = Files.findFile(god_key_file_my);
  if (null != f)
    Files.deleteFile(f);
}
origin: nutzam/nutz

public static File createFileIfNoExists2(String path) {
  try {
    return createFileIfNoExists(path);
  }
  catch (IOException e) {
    throw Lang.wrapThrow(e);
  }
}
origin: nutzam/nutz

public void free() throws SQLException {
  Files.deleteFile(file);
}
origin: nutzam/nutz

/**
 * 获取输出流
 * 
 * @param path
 *            文件路径
 * @param enc
 *            文件路径编码
 * 
 * @return 输出流
 */
public static InputStream findFileAsStream(String path, String enc) {
  return findFileAsStream(path, Files.class, enc);
}
origin: nutzam/nutz

return ImageIO.read(Files.checkFile(img.toString()));
Files.write(tmp, img);
try {
  return read(tmp);
origin: nutzam/nutz

/**
 * 将一个目录下的特殊名称的目录彻底删除,比如 '.svn' 或者 '.cvs'
 * 
 * @param dir
 *            目录
 * @param name
 *            要清除的目录名
 * @throws IOException
 */
public static void cleanAllFolderInSubFolderes(File dir, String name) throws IOException {
  File[] files = dir.listFiles();
  if (files == null)
    return;
  for (File d : files) {
    if (d.isDirectory())
      if (d.getName().equalsIgnoreCase(name))
        deleteDir(d);
      else
        cleanAllFolderInSubFolderes(d, name);
  }
}
origin: nutzam/nutzwx

byte[] data = Files.readBytes(mf);
if (data[0] == '{') { // 看上去是个json,悲催了...
origin: nutzam/nutz-web

private String doScan() {
  final StringBuilder sb = new StringBuilder();
  final HashMap<String, Boolean> paths = new HashMap<String, Boolean>();
  File home = Files.createDirIfNoExists(rsHome);
  Context context = Lang.context();
  context.set(Webs.RS, rs);
    File theF = Files.getFile(home, path);
org.nutz.langFiles

Javadoc

文件操作的帮助函数

Most used methods

  • 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
  • makeDir
    创建新目录,如果父目录不存在,也一并创建。可接受 null 参数
  • getName,
  • makeDir,
  • read,
  • checkFile,
  • clearDir,
  • copy,
  • copyDir,
  • copyFile,
  • copyOnWrite,
  • createNewFile

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • orElseThrow (Optional)
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now