ch.cyberduck.core.Local.getOutputStream()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中ch.cyberduck.core.Local.getOutputStream()方法的一些代码示例,展示了Local.getOutputStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Local.getOutputStream()方法的具体详情如下:
包路径:ch.cyberduck.core.Local
类名称:Local
方法名:getOutputStream

Local.getOutputStream介绍

暂无

代码示例

代码示例来源:origin: iterate-ch/cyberduck

public OutputStream getOutputStream(final boolean append) throws AccessDeniedException {
  return this.getOutputStream(path, append);
}

代码示例来源:origin: iterate-ch/cyberduck

private void save(final Properties properties) {
  try (OutputStream out = file.getOutputStream(false)) {
    properties.store(out, "Credentials");
  }
  catch(AccessDeniedException e) {
    log.warn(String.format("Failure saving credentials to %s. %s", file.getAbsolute(), e.getDetail()));
  }
  catch(IOException e) {
    log.warn(String.format("Failure saving credentials to %s. %s", file.getAbsolute(), e.getMessage()));
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public OutputStream getOutputStream(boolean append) throws AccessDeniedException {
  final NSURL resolved;
  try {
    resolved = this.lock(this.exists());
    if(null == resolved) {
      return super.getOutputStream(append);
    }
  }
  catch(LocalAccessDeniedException e) {
    log.warn(String.format("Failure obtaining lock for %s. %s", this, e.getMessage()));
    return super.getOutputStream(append);
  }
  try {
    return new ProxyOutputStream(new FileOutputStream(new File(resolved.path()), append)) {
      @Override
      public void close() throws IOException {
        try {
          super.close();
        }
        finally {
          release(resolved);
        }
      }
    };
  }
  catch(FileNotFoundException e) {
    throw new LocalAccessDeniedException(e.getMessage(), e);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
  public void write(final S item, final Local file) throws AccessDeniedException {
    final String content = item.<NSDictionary>serialize(SerializerFactory.get()).toXMLPropertyList();
    final OutputStream out = file.getOutputStream(false);
    try {
      IOUtils.write(content, out, Charset.forName("UTF-8"));
    }
    catch(IOException e) {
      throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
    }
    finally {
      IOUtils.closeQuietly(out);
    }
  }
}

代码示例来源:origin: iterate-ch/cyberduck

public void copy(final Local copy, final CopyOptions options) throws AccessDeniedException {
  if(copy.equals(this)) {
    log.warn(String.format("%s and %s are identical. Not copied.", this.getName(), copy.getName()));
  }
  else {
    if(log.isDebugEnabled()) {
      log.debug(String.format("Copy to %s with options %s", copy, options));
    }
    InputStream in = null;
    OutputStream out = null;
    try {
      in = this.getInputStream();
      out = copy.getOutputStream(options.append);
      IOUtils.copy(in, out);
    }
    catch(IOException e) {
      throw new LocalAccessDeniedException(MessageFormat.format(
        LocaleFactory.localizedString("Cannot copy {0}", "Error"), this.getName()), e);
    }
    finally {
      IOUtils.closeQuietly(in);
      IOUtils.closeQuietly(out);
    }
  }
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public void write(final Collection<S> collection, final Local file) throws AccessDeniedException {
  final NSArray list = new NSArray(collection.size());
  int i = 0;
  for(S bookmark : collection) {
    list.setValue(i, bookmark.<NSDictionary>serialize(SerializerFactory.get()));
    i++;
  }
  final String content = list.toXMLPropertyList();
  final OutputStream out = file.getOutputStream(false);
  try {
    IOUtils.write(content, out, Charset.forName("UTF-8"));
  }
  catch(IOException e) {
    throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
  }
  finally {
    IOUtils.closeQuietly(out);
  }
}

代码示例来源:origin: iterate-ch/cyberduck

/**
 * Write temporary file with data
 *
 * @param icon Base64 encoded image information
 * @return Path to file
 */
private Local write(final String icon) {
  if(StringUtils.isBlank(icon)) {
    return null;
  }
  final byte[] favicon = Base64.decodeBase64(icon);
  final Local file = TemporaryFileServiceFactory.get().create(new AlphanumericRandomStringService().random());
  try {
    new DefaultLocalTouchFeature().touch(file);
    final OutputStream out = file.getOutputStream(false);
    try {
      IOUtils.write(favicon, out);
    }
    finally {
      IOUtils.closeQuietly(out);
    }
    return file;
  }
  catch(IOException | AccessDeniedException e) {
    log.error("Error writing temporary file", e);
  }
  return null;
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public void download(final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener,
           final TransferStatus status, final ConnectionCallback connectionCallback, final PasswordCallback passwordCallback) throws BackgroundException {
  final InputStream in = reader.read(file, status, connectionCallback);
  final OutputStream out = local.getOutputStream(status.isAppend());
  new StreamCopier(status, status)
      .withOffset(0L)
      .withLimit(status.getLength())
      .withListener(listener)
      .transfer(new ThrottledInputStream(in, throttle), out);
}

相关文章