Java Code Examples for jcifs.smb.SmbFile#close()

The following examples show how to use jcifs.smb.SmbFile#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnumTest.java    From jcifs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testDirDosFilterEnum () throws CIFSException, MalformedURLException, UnknownHostException {
    try ( SmbFile f = createTestDirectory() ) {
        try ( SmbFile a = new SmbFile(f, "a.txt");
              SmbFile b = new SmbFile(f, "b.txt");
              SmbFile c = new SmbFile(f, "c.bar") ) {

            a.createNewFile();
            b.createNewFile();
            c.createNewFile();

            SmbFile[] files = f.listFiles(new DosFileFilter("*.txt", -1));
            assertNotNull(files);
            assertEquals(2, files.length);
            for ( SmbFile cf : files ) {
                assertTrue(cf.exists());
                cf.close();
            }
        }
        finally {
            f.delete();
        }
    }
}
 
Example 2
Source File: EnumTest.java    From jcifs-ng with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testDirDosFilterEnum () throws CIFSException, MalformedURLException, UnknownHostException {
    try ( SmbFile f = createTestDirectory() ) {
        try ( SmbFile a = new SmbFile(f, "a.txt");
              SmbFile b = new SmbFile(f, "b.txt");
              SmbFile c = new SmbFile(f, "c.bar") ) {

            a.createNewFile();
            b.createNewFile();
            c.createNewFile();

            SmbFile[] files = f.listFiles(new DosFileFilter("*.txt", -1));
            assertNotNull(files);
            assertEquals(2, files.length);
            for ( SmbFile cf : files ) {
                assertTrue(cf.exists());
                cf.close();
            }
        }
        finally {
            f.delete();
        }
    }
}
 
Example 3
Source File: EnumTest.java    From jcifs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testDirEnum () throws CIFSException, MalformedURLException, UnknownHostException {
    try ( SmbFile f = createTestDirectory() ) {
        try ( SmbFile a = new SmbFile(f, "a");
              SmbFile b = new SmbFile(f, "b");
              SmbFile c = new SmbFile(f, "c") ) {

            a.createNewFile();
            b.createNewFile();
            c.createNewFile();

            String[] names = f.list();
            assertNotNull(names);
            assertEquals(3, names.length);
            Arrays.sort(names);
            Assert.assertArrayEquals(new String[] {
                "a", "b", "c"
            }, names);

            SmbFile[] files = f.listFiles();
            assertNotNull(files);
            assertEquals(3, files.length);

            for ( SmbFile cf : files ) {
                assertTrue(cf.exists());
                cf.close();
            }
        }
        finally {
            f.delete();
        }
    }
}
 
Example 4
Source File: EnumTest.java    From jcifs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testPatternEnum () throws CIFSException, MalformedURLException, UnknownHostException {
    try ( SmbFile f = createTestDirectory() ) {
        try ( SmbFile a = new SmbFile(f, "a.txt");
              SmbFile b = new SmbFile(f, "b.txt");
              SmbFile c = new SmbFile(f, "c.bar") ) {

            a.createNewFile();
            b.createNewFile();
            c.createNewFile();

            SmbFile[] files = f.listFiles("*.txt");
            assertNotNull(files);
            assertEquals(2, files.length);
            for ( SmbFile cf : files ) {
                assertTrue(cf.exists());
                cf.close();
            }

            int n = 0;
            try ( CloseableIterator<SmbResource> children = f.children("*.txt") ) {
                while ( children.hasNext() ) {
                    try ( SmbResource r = children.next() ) {
                        assertTrue(r.exists());
                        n++;
                    }
                }
            }
            assertEquals(2, n);
        }
        finally {
            f.delete();
        }
    }
}
 
Example 5
Source File: EnumTest.java    From jcifs-ng with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testDirEnum () throws CIFSException, MalformedURLException, UnknownHostException {
    try ( SmbFile f = createTestDirectory() ) {
        try ( SmbFile a = new SmbFile(f, "a");
              SmbFile b = new SmbFile(f, "b");
              SmbFile c = new SmbFile(f, "c") ) {

            a.createNewFile();
            b.createNewFile();
            c.createNewFile();

            String[] names = f.list();
            assertNotNull(names);
            assertEquals(3, names.length);
            Arrays.sort(names);
            Assert.assertArrayEquals(new String[] {
                "a", "b", "c"
            }, names);

            SmbFile[] files = f.listFiles();
            assertNotNull(files);
            assertEquals(3, files.length);

            for ( SmbFile cf : files ) {
                assertTrue(cf.exists());
                cf.close();
            }
        }
        finally {
            f.delete();
        }
    }
}
 
Example 6
Source File: EnumTest.java    From jcifs-ng with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testPatternEnum () throws CIFSException, MalformedURLException, UnknownHostException {
    try ( SmbFile f = createTestDirectory() ) {
        try ( SmbFile a = new SmbFile(f, "a.txt");
              SmbFile b = new SmbFile(f, "b.txt");
              SmbFile c = new SmbFile(f, "c.bar") ) {

            a.createNewFile();
            b.createNewFile();
            c.createNewFile();

            SmbFile[] files = f.listFiles("*.txt");
            assertNotNull(files);
            assertEquals(2, files.length);
            for ( SmbFile cf : files ) {
                assertTrue(cf.exists());
                cf.close();
            }

            int n = 0;
            try ( CloseableIterator<SmbResource> children = f.children("*.txt") ) {
                while ( children.hasNext() ) {
                    try ( SmbResource r = children.next() ) {
                        assertTrue(r.exists());
                        n++;
                    }
                }
            }
            assertEquals(2, n);
        }
        finally {
            f.delete();
        }
    }
}