Package winterwell.utils

Examples of winterwell.utils.IORException$FileNotFoundException


    for (int i = 2; i < 10000; i++) {
      File f = new File(path, preType + i + dotType);
      if (!f.exists())
        return f;
    }
    throw new IORException("Could not find a non-existing file name for "
        + file);
  }
View Full Code Here


  public static BufferedReader getReader(File file) {
    try {
      return getReader(new FileInputStream(file));
    } catch (FileNotFoundException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

    try {
      InputStreamReader reader = new InputStreamReader(in, UTF8);
      // \uFFFD
      return new BufferedReader(reader);
    } catch (Exception e) {
      throw new IORException(e);
    }
  }
View Full Code Here

  public static File getWorkingDirectory() {
    // String prop = System.getProperty("user.dir");
    try {
      return new File(".").getCanonicalFile();
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

      } catch (UnsupportedEncodingException e) {
        return new BufferedWriter(new OutputStreamWriter(
            new FileOutputStream(file)));
      }
    } catch (IOException ex) {
      throw new IORException(ex);
    }
  }
View Full Code Here

  public static BufferedWriter getWriter(OutputStream out) {
    try {
      OutputStreamWriter writer = new OutputStreamWriter(out, UTF8);
      return new BufferedWriter(writer);
    } catch (UnsupportedEncodingException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

   * @return files in dir matching the regex pattern
   * @see #find(File, String) which is recursive
   */
  public static File[] ls(File dir, String fileNameRegex) {
    if (!dir.isDirectory())
      throw new IORException(dir + " is not a valid directory");
    return dir.listFiles(getRegexFilter(".*" + fileNameRegex));
  }
View Full Code Here

          + original + " = " + out);
    // the source must exist
    if (!original.exists())
      throw new IORException.FileNotFoundException(original);
    if (!original.isDirectory() && !original.isFile())
      throw new IORException("Weird: " + original);
    if (out.exists()) {
      if (overwrite) {
        FileUtils.delete(out);
      } else
        throw new IORException("Creating symlink failed: " + out
            + " already exists.");
    }
    try {
      original = original.getCanonicalFile();
      ShellScript ss = new ShellScript("ln -s " + original + " " + out);
View Full Code Here

        }
        cnt++;
      }
      return cnt;
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

      FileInputStream in = new FileInputStream(file);
      FileOutputStream out = new FileOutputStream(temp, true);
      copy(in, out);
      move(temp, file);
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

TOP

Related Classes of winterwell.utils.IORException$FileNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.