当前位置: 首页>>代码示例>>Java>>正文


Java ClosedDirectoryStreamException类代码示例

本文整理汇总了Java中java.nio.file.ClosedDirectoryStreamException的典型用法代码示例。如果您正苦于以下问题:Java ClosedDirectoryStreamException类的具体用法?Java ClosedDirectoryStreamException怎么用?Java ClosedDirectoryStreamException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClosedDirectoryStreamException类属于java.nio.file包,在下文中一共展示了ClosedDirectoryStreamException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOpenDirectoryStreamsClosed

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Test
public void testOpenDirectoryStreamsClosed() throws IOException {
  Path p = fs.getPath("/foo");
  Files.createDirectory(p);

  try (DirectoryStream<Path> stream = Files.newDirectoryStream(p)) {

    fs.close();

    try {
      stream.iterator();
      fail();
    } catch (ClosedDirectoryStreamException expected) {
    }
  }
}
 
开发者ID:google,项目名称:jimfs,代码行数:17,代码来源:JimfsFileSystemCloseTest.java

示例2: iterator

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Override
public synchronized Iterator<Path> iterator() {
    if (isClosed)
        throw new ClosedDirectoryStreamException();
    if (itr != null)
        throw new IllegalStateException("Iterator has already been returned");

    try {
        itr = zipfs.iteratorOf(path, filter);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    return new Iterator<Path>() {
        private Path next;
        @Override
        public boolean hasNext() {
            if (isClosed)
                return false;
            return itr.hasNext();
        }

        @Override
        public synchronized Path next() {
            if (isClosed)
                throw new NoSuchElementException();
            return itr.next();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:ZipDirectoryStream.java

示例3: iterator

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Override
public synchronized Iterator<Path> iterator() {
    if (isClosed)
        throw new ClosedDirectoryStreamException();
    if (itr != null)
        throw new IllegalStateException("Iterator has already been returned");
    try {
        itr = dir.jrtfs.iteratorOf(dir, filter);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    return new Iterator<Path>() {
        @Override
        public boolean hasNext() {
            synchronized (JrtDirectoryStream.this) {
                if (isClosed)
                    return false;
                return itr.hasNext();
            }
        }

        @Override
        public Path next() {
            synchronized (JrtDirectoryStream.this) {
                if (isClosed)
                    throw new NoSuchElementException();
                return itr.next();
            }
        }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:JrtDirectoryStream.java

示例4: iterator

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Override
public synchronized Iterator<Path> iterator() {
    if (isClosed)
        throw new ClosedDirectoryStreamException();
    if (itr != null)
        throw new IllegalStateException("Iterator has already been returned");
    try {
        itr = dir.jrtfs.iteratorOf(dir, filter);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    return new Iterator<Path>() {
        private Path next;
        @Override
        public synchronized boolean hasNext() {
            if (isClosed)
                return false;
            return itr.hasNext();
        }

        @Override
        public synchronized Path next() {
            if (isClosed)
                throw new NoSuchElementException();
            return itr.next();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:34,代码来源:JrtDirectoryStream.java

示例5: assertNotClosed

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Override
public void assertNotClosed() throws FileSystemException {
    if(closed) {
        throw new ClosedDirectoryStreamException(); 
    }
    
}
 
开发者ID:sbridges,项目名称:ephemeralfs,代码行数:8,代码来源:EphemeralFsSecureDirectoryStream.java

示例6: iterator

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Override
public synchronized Iterator<Path> iterator() {
    if (isClosed)
        throw new ClosedDirectoryStreamException();
    if (itr != null)
        throw new IllegalStateException("Iterator has already been returned");

    try {
        itr = jrtfs.iteratorOf(path, childPrefix, filter);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    return new Iterator<Path>() {
        @Override
        public boolean hasNext() {
            if (isClosed)
                return false;
            return itr.hasNext();
        }

        @Override
        public synchronized Path next() {
            if (isClosed)
                throw new NoSuchElementException();
            return itr.next();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
开发者ID:forax,项目名称:jigsaw-jrtfs,代码行数:34,代码来源:JrtDirectoryStream.java

示例7: iterator

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Override
public synchronized Iterator<Path> iterator() {
	if (isClosed) {
		throw new ClosedDirectoryStreamException();
	}
	if (itr != null) {
		throw new IllegalStateException("Iterator has already been returned");
	}

	try {
		itr = tarfs.iteratorOf(path, filter);
	} catch (IOException e) {
		throw new IllegalStateException(e);
	}
	return new Iterator<Path>() {
		@SuppressWarnings("unused")
		private Path next;
		@Override
		public boolean hasNext() {
			if (isClosed) {
				return false;
			}
			return itr.hasNext();
		}

		@Override
		public synchronized Path next() {
			if (isClosed) {
				throw new NoSuchElementException();
			}
			return itr.next();
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
	};
}
 
开发者ID:PeterLaker,项目名称:archive-fs,代码行数:40,代码来源:TarDirectoryStream.java

示例8: testReadFromDirStreamOfClosedFSThrows

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Test( expected = ClosedDirectoryStreamException.class )
@Category( Closable.class )
@SuppressWarnings( "PMD.UnusedLocalVariable" )
public void testReadFromDirStreamOfClosedFSThrows() throws IOException {
    for ( Path kid : getClosedDirStream()) {
    }
}
 
开发者ID:openCage,项目名称:niotest,代码行数:8,代码来源:Tests07Closed.java

示例9: checkClosed

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
void checkClosed() {
    if (dir == null) {
        throw new ClosedDirectoryStreamException();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:6,代码来源:MCRDirectoryStream.java

示例10: iterator

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
@Nonnull
@Override
public Iterator<Path> iterator() {
  final Iterator<String> childrenIt = children.iterator();
  return new Iterator<Path>() {

    private Path next;

    private boolean findNext() {
      while(childrenIt.hasNext()) {
        String child = childrenIt.next();
        GitPath childPath = parent.resolve(child);
        try {
          if(filter == null || filter.accept(childPath)) {
            next = childPath;
            return true;
          }
        } catch(IOException ignore) {
        }
      }
      return false;
    }

    @Override
    public boolean hasNext() throws ClosedDirectoryStreamException {
      checkNotClosed();
      return next != null || findNext();
    }

    @Nonnull
    @Override
    public Path next() throws ClosedDirectoryStreamException, NoSuchElementException {
      checkNotClosed();
      if(next != null || hasNext()) {
        Path ret = next;
        next = null;
        return ret;
      }
      throw new NoSuchElementException();
    }

    @Override
    public void remove() throws UnsupportedOperationException {
      throw new UnsupportedOperationException();
    }
  };
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:48,代码来源:GfsDirectoryStream.java

示例11: checkNotClosed

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
private void checkNotClosed() throws ClosedDirectoryStreamException {
  if(closed)
    throw new ClosedDirectoryStreamException();
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:5,代码来源:GfsDirectoryStream.java

示例12: checkOpen

import java.nio.file.ClosedDirectoryStreamException; //导入依赖的package包/类
protected synchronized void checkOpen() {
  if (!open) {
    throw new ClosedDirectoryStreamException();
  }
}
 
开发者ID:google,项目名称:jimfs,代码行数:6,代码来源:JimfsSecureDirectoryStream.java


注:本文中的java.nio.file.ClosedDirectoryStreamException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。