Package com.google.common.io

Examples of com.google.common.io.Closer.register()


    public Object addingService(ServiceReference reference) {
        Object service = bundleContext.getService(reference);

        if (service instanceof Observer) {
            Closer subscription = Closer.create();
            BackgroundObserver observer = subscription.register(
                    new BackgroundObserver((Observer) service, executor));
            subscription.register(
                    observable.addObserver(observer));
            subscriptions.put(reference, subscription);
            return service;
View Full Code Here


        if (service instanceof Observer) {
            Closer subscription = Closer.create();
            BackgroundObserver observer = subscription.register(
                    new BackgroundObserver((Observer) service, executor));
            subscription.register(
                    observable.addObserver(observer));
            subscriptions.put(reference, subscription);
            return service;
        } else {
            bundleContext.ungetService(reference);
View Full Code Here

   * @param dataFile the source data format
   * @throws IOException
   */
  private void processRDataFile(File dataFile) throws IOException {
    Closer closer = Closer.create();
    InputStream in = closer.register(DatasetsBuilder.decompress(dataFile));
    SEXP exp;
    try {
      RDataReader reader = new RDataReader(in);
      exp = reader.readFile();
    } catch(Throwable e) {
View Full Code Here

  }

  public static ImmutableMap<String, String> loadProperties(ByteSource is) throws IOException {
    Properties props = new Properties();
    Closer closer = Closer.create();
    InputStream in = closer.register(is.openStream());
    try {
      props.load(in);
    } finally {
      closer.close();
    }
View Full Code Here

    manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
    manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, jarFile.getName());

    Closer closer = Closer.create();
    try {
      FileOutputStream fileOut = closer.register(new FileOutputStream(jarFile));
      JarOutputStream jarOut = closer.register(new JarOutputStream(fileOut));
      for (String entry : entries) {
        jarOut.putNextEntry(new ZipEntry(entry));
        Resources.copy(ClassPathTest.class.getResource(entry), jarOut);
        jarOut.closeEntry();
View Full Code Here

    manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, jarFile.getName());

    Closer closer = Closer.create();
    try {
      FileOutputStream fileOut = closer.register(new FileOutputStream(jarFile));
      JarOutputStream jarOut = closer.register(new JarOutputStream(fileOut));
      for (String entry : entries) {
        jarOut.putNextEntry(new ZipEntry(entry));
        Resources.copy(ClassPathTest.class.getResource(entry), jarOut);
        jarOut.closeEntry();
      }
View Full Code Here

    byte[] output;
    Closer closer = Closer.create();

    try {
      ByteArrayOutputStream byteArrayOutputStream = closer.register(new ByteArrayOutputStream());
      DataOutputStream dataOutputStream = closer.register(new DataOutputStream(byteArrayOutputStream));
      PolymorphicWritable.write(dataOutputStream, lr);
      output = byteArrayOutputStream.toByteArray();
    } finally {
      closer.close();
View Full Code Here

    byte[] output;
    Closer closer = Closer.create();

    try {
      ByteArrayOutputStream byteArrayOutputStream = closer.register(new ByteArrayOutputStream());
      DataOutputStream dataOutputStream = closer.register(new DataOutputStream(byteArrayOutputStream));
      PolymorphicWritable.write(dataOutputStream, lr);
      output = byteArrayOutputStream.toByteArray();
    } finally {
      closer.close();
    }
View Full Code Here

    }

    OnlineLogisticRegression read;

    try {
      ByteArrayInputStream byteArrayInputStream = closer.register(new ByteArrayInputStream(output));
      DataInputStream dataInputStream = closer.register(new DataInputStream(byteArrayInputStream));
      read = closer.register(PolymorphicWritable.read(dataInputStream, OnlineLogisticRegression.class));
    } finally {
      closer.close();
    }
View Full Code Here

    OnlineLogisticRegression read;

    try {
      ByteArrayInputStream byteArrayInputStream = closer.register(new ByteArrayInputStream(output));
      DataInputStream dataInputStream = closer.register(new DataInputStream(byteArrayInputStream));
      read = closer.register(PolymorphicWritable.read(dataInputStream, OnlineLogisticRegression.class));
    } finally {
      closer.close();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.