Package winterwell.utils

Examples of winterwell.utils.IORException


  public void flush() {
    try {
      out.flush();
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here


    if (!append)
      return;
    try {
      out = FileUtils.getWriter(new FileOutputStream(file, true));
    } catch (FileNotFoundException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

      StrUtils.pop(sb, 1);
      sb.append(LINEEND);
      // write
      out.append(sb);
    } catch (IOException ex) {
      throw new IORException(ex);
    }
  }
View Full Code Here

        // close the stream
        close();
      }
      return next;
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

    try {
      BufferedWriter w = getWriter(new FileOutputStream(file, true));
      w.write(string);
      close(w);
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

    if (in.isDirectory()) {
      ArrayList<File> failed = new ArrayList<File>();
      copyDir(in, out, overwrite, failed);
      // Failed any?
      if (failed.size() != 0)
        throw new IORException("Could not copy files: "
            + Printer.toString(failed));
      return out;
    }
    if (out.isDirectory()) {
      out = new File(out, in.getName());
    }
    try {
      if (out.exists() && !overwrite)
        throw new IORException("Copy failed: " + out
            + " already exists.");
      // TODO use NIO for efficiency!
      copy(new FileInputStream(in), out);
      return out;
    } catch (IOException e) {
      throw new IORException(e.getMessage() + " copying "
          + in.getAbsolutePath() + " to " + out.getAbsolutePath());
    }
  }
View Full Code Here

   * @param out
   */
  public static void copy(InputStream in, File out) {
    assert in != null && out != null;
    if (!out.getParentFile().isDirectory())
      throw new IORException("Directory does not exist: "
          + out.getParentFile());
    try {
      FileOutputStream outStream = new FileOutputStream(out);
      copy(in, outStream);
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

          break;
        }
        out.write(bytes, 0, len);
      }
    } catch (IOException e) {
      throw new IORException(e);
    } finally {
      close(in);
      close(out);
    }
  }
View Full Code Here

   */
  public static File createTempFile(String prefix, String suffix) {
    try {
      return File.createTempFile(prefix, suffix);
    } catch (IOException e) {
      throw new IORException(e);
    }
  }
View Full Code Here

   *            Delete this directory & everything in it (recurses through
   *            directories).
   */
  public static void deleteDir(File file) {
    if (!file.isDirectory())
      throw new IORException(file + " is not a directory");
    if (isSymLink(file)) {
      // Just delete the link, not the contents
      delete(file);
      return;
    }
View Full Code Here

TOP

Related Classes of winterwell.utils.IORException

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.