Tabnine Logo
IO
Code IndexAdd Tabnine to your IDE (free)

How to use
IO
in
aQute.lib.io

Best Java code snippets using aQute.lib.io.IO (Showing top 20 results out of 315)

origin: biz.aQute.bnd/biz.aQute.bndlib

private ByteBuffer getBuffer() throws Exception {
  if (buffer != null) {
    return buffer;
  }
  if (size == -1) {
    return buffer = ByteBuffer.wrap(IO.read(zip.getInputStream(entry)));
  }
  ByteBuffer bb = IO.copy(zip.getInputStream(entry), ByteBuffer.allocate((int) size));
  bb.flip();
  return buffer = bb;
}
origin: biz.aQute.bnd/biz.aQute.bndlib

private static String getMessage(HttpURLConnection conn) {
  try (InputStream in = conn.getErrorStream()) {
    if (in != null)
      return IO.collect(in);
  } catch (Exception e) {
    // Ignore
  }
  return "";
}
origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Delete a cache entry
 */
@Override
public boolean deleteCache(byte[] id) throws Exception {
  File dir = IO.getFile(cache, Hex.toHexString(id));
  if (dir.isDirectory()) {
    IO.delete(dir);
    return true;
  }
  return false;
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public static Path copy(InputStream in, Path path) throws IOException {
  try (FileChannel out = writeChannel(path)) {
    copy(in, out);
  }
  return path;
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public static Writer copy(InputStream in, Writer w, Charset charset) throws IOException {
  return copy(reader(in, charset), w);
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public static String collect(Path path, Charset encoding) throws IOException {
  return collect(reader(path, encoding));
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public static OutputStream copy(Reader r, OutputStream out, Charset charset) throws IOException {
  Writer w = writer(out, charset);
  try {
    copy(r, w);
    return out;
  } finally {
    w.flush();
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void delete(Project p) throws IOException {
  File root = p.getWorkspace()
    .getFile("pom.xml");
  String rootPom = IO.collect(root);
  if (rootPom.contains(getTag(p))) {
    rootPom = rootPom.replaceAll("\n\\s*" + getTag(p) + "\\s*", "\n");
    IO.store(rootPom, root);
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Deletes and creates directories
 */
public static void initialize(File dir) {
  try {
    deleteWithException(dir);
    mkdirs(dir);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public void save(File location) throws IOException {
  if (location.getName()
    .endsWith(".gz"))
    compress = true;
  IO.mkdirs(location.getParentFile());
  File tmp = IO.createTempFile(location.getParentFile(), "index", ".xml");
  try (OutputStream out = IO.outputStream(tmp)) {
    save(out);
  }
  IO.rename(tmp, location);
}
origin: biz.aQute.bnd/biz.aQute.bnd

private synchronized void save() throws Exception {
  Path index = indexFile.toPath();
  Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null);
  try (PrintWriter pw = IO.writer(tmp)) {
    archives.keySet()
      .stream()
      .sorted()
      .forEachOrdered(archive -> pw.println(archive));
  }
  IO.rename(tmp, index);
  lastModified = indexFile.lastModified();
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public static URL toURL(String s, File base) throws MalformedURLException {
  int n = s.indexOf(':');
  if (n > 0 && n < 10) {
    // is url
    return new URL(s);
  }
  return getFile(base, s).toURI()
    .toURL();
}
origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void created(Project p) throws IOException {
  Workspace workspace = p.getWorkspace();
  File source = workspace.getFile("ant/project.xml");
  File dest = p.getFile("build.xml");
  if (source.isFile())
    IO.copy(source, dest);
  else
    IO.store(DEFAULT, dest);
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public static void store(Object o, OutputStream out, Charset encoding) throws IOException {
  Writer w = writer(out, encoding);
  try {
    store(o, w);
  } finally {
    w.flush();
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void write(OutputStream out) throws Exception {
  if (buffer != null) {
    IO.copy(buffer(), out);
  } else {
    IO.copy(zip.getInputStream(entry), out);
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void close() throws IOException {
  /*
   * Allow original buffer to be garbage collected and prevent it being
   * remapped for this FileResouce.
   */
  buffer = CLOSED;
  if (deleteOnClose)
    IO.delete(file);
}
origin: biz.aQute.bnd/biz.aQute.bndlib

private void copyResource(File dir, String path, Resource resource) throws Exception {
  File to = IO.getBasedFile(dir, path);
  IO.mkdirs(to.getParentFile());
  IO.copy(resource.openInputStream(), to);
}
origin: biz.aQute.bnd/biz.aQute.repository

void saveSHAFile(String contents) {
  try {
    IO.store(contents, shaFile);
  } catch (IOException e) {
    IO.delete(shaFile);
    // Errors saving the SHA should not interfere with the download
    if (reporter != null)
      reporter.exception(e, "Failed to save SHA file %s (%s)", shaFile, e);
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Deletes the specified file. Folders are recursively deleted.<br>
 * Throws exception if any of the files could not be deleted.
 *
 * @param file file to be deleted
 * @throws IOException if the file (or contents of a folder) could not be
 *             deleted
 */
public static void deleteWithException(File file) throws IOException {
  deleteWithException(file.toPath());
}
origin: biz.aQute.bnd/biz.aQute.bndlib

public LineCollection(File in) throws IOException {
  this(IO.reader(in, UTF_8));
}
aQute.lib.ioIO

Most used methods

  • copy
  • collect
  • getFile
  • deleteWithException
    Deletes the specified path. Folders are recursively deleted. Throws exception if any of the files co
  • reader
  • store
  • writer
  • delete
    Deletes the specified path. Folders are recursively deleted. If file(s) cannot be deleted, no feedba
  • read
  • rename
    Renames from to to replacing the target file if necessary.
  • isSymbolicLink
  • stream
  • isSymbolicLink,
  • stream,
  • traverse,
  • close,
  • createSymbolicLink,
  • createSymbolicLinkOrCopy,
  • createTempFile,
  • decode,
  • mkdirs,
  • normalizePath

Popular in Java

  • Making http post requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • putExtra (Intent)
  • Kernel (java.awt.image)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Socket (java.net)
    Provides a client-side TCP socket.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JLabel (javax.swing)
  • 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