Package java.io

Examples of java.io.Closeable


   public void testClose()
   {
      assertFalse(Safe.close(null));
      assertTrue(Safe.close(new ByteArrayOutputStream()));
      assertFalse(Safe.close(new Closeable()
      {
         public void close() throws IOException
         {
            throw new IOException();
         }
      }));
      assertFalse(Safe.close(new Closeable()
      {
         public void close() throws IOException
         {
            throw new RuntimeException();
         }
      }));
      final Error expectedError = new Error();
      try
      {
         Safe.close(new Closeable()
         {
            public void close() throws IOException
            {
               throw expectedError;
            }
View Full Code Here


      VirtualFile backupRoot = VFS.getChild("/profileservice/originals/");
     
      for (Map.Entry<String, URI> entry : namedURIMap.entrySet())
      {
         VirtualFile backup = backupRoot.getChild(profileName).getChild("roots").getChild(entry.getKey());
         Closeable closeable =  mountRepositoryRoot(entry.getValue(), backup);
         vfCache.put(entry.getKey(), backup);
         mounts.put(entry.getKey(), closeable);
      }
   }
View Full Code Here

   VirtualFile backup(String profileName, String name, VirtualFile original) throws IOException
   {
      File realFile = original.getPhysicalFile();
      String hash = Integer.toHexString(realFile.toURI().hashCode());
      VirtualFile backup = originals.getChild(profileName).getChild(hash + realFile.getName());
      Closeable closeable = VFS.mountReal(realFile, backup);
      mounts.put(name, closeable);
      return backup;
   }
View Full Code Here

    * @param name
    * @throws IOException
    */
   void cleanup(String name) throws IOException
   {
      Closeable closeable = mounts.remove(name);
      if(closeable != null)
      {
         closeable.close();
      }
   }
View Full Code Here

      extensionSwapClient = new ExtensionSwapClient(websiteHostname, windowContext, userPreferences);
    }
    ExtensionSwapInstallationHttpContainer container = new ExtensionSwapInstallationHttpContainer(extensionSwapClient,
        userPreferences);

    final Closeable closeableConnection = container.initialize();
    if (closeableConnection != null) {
      windowContext.addExitActionListener(new ExitActionListener() {
        @Override
        public void exit(int statusCode) {
          FileHelper.safeClose(closeableConnection);
View Full Code Here

        return valuesList;
    }

    public static void close(InputSource is) {
        Closeable c = is.getByteStream();
        if (c == null) {
            c = is.getCharacterStream();
        }
        if (c != null) {
            try {
                c.close();
            } catch (IOException e) {
                // Ignore
            }
        }
    }
View Full Code Here

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class StreamsTestCase extends TestCase {
    public void testSimpleClose() throws Exception {
        Closeable closeable = mock(Closeable.class);
        Streams.close(closeable);
        verify(closeable).close();
    }
View Full Code Here

        Streams.close(closeable);
        verify(closeable).close();
    }

    public void testCloseWithNullParameter() throws Exception {
        Closeable closeable = mock(Closeable.class);
        Streams.close(closeable, null);
        verify(closeable).close();
    }
View Full Code Here

            s = new Socket();
            s.connect(endpoint,3000);
            out = new SocketOutputStream(s);
        }

        closables.add(new Closeable() {
            public void close() throws IOException {
                s.close();
            }
        });
View Full Code Here

        setName("sockmon");
        setDaemon(true);
    }

    private static Closeable wrapSocket(final Socket socket) {
        return new Closeable() {
            @Override
            public void close()
                    throws IOException {
                socket.close();
            }
View Full Code Here

TOP

Related Classes of java.io.Closeable

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.