类java.nio.file.ClosedDirectoryStreamException源码实例Demo

下面列出了怎么用java.nio.file.ClosedDirectoryStreamException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jimfs   文件: JimfsFileSystemCloseTest.java
@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) {
    }
  }
}
 
源代码2 项目: dragonwell8_jdk   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码3 项目: TencentKona-8   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码4 项目: jdk8u60   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码5 项目: openjdk-jdk8u   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码7 项目: Bytecoder   文件: JrtDirectoryStream.java
@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();
            }
        }
    };
}
 
源代码8 项目: openjdk-jdk9   文件: JrtDirectoryStream.java
@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();
            }
        }
    };
}
 
源代码9 项目: openjdk-jdk9   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码10 项目: jdk8u-jdk   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码11 项目: hottub   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码12 项目: openjdk-8-source   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码13 项目: openjdk-8   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码14 项目: jdk8u_jdk   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码15 项目: jdk8u-jdk   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码16 项目: jdk8u-dev-jdk   文件: ZipDirectoryStream.java
@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();
        }
    };
}
 
源代码17 项目: mycore   文件: MCRDirectoryStream.java
void checkClosed() {
    if (isClosed) {
        throw new ClosedDirectoryStreamException();
    }
}
 
源代码18 项目: mycore   文件: MCRDirectoryStream.java
void checkClosed() {
    if (dir == null) {
        throw new ClosedDirectoryStreamException();
    }
}
 
源代码19 项目: ParallelGit   文件: GfsDirectoryStream.java
@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();
    }
  };
}
 
源代码20 项目: ParallelGit   文件: GfsDirectoryStream.java
private void checkNotClosed() throws ClosedDirectoryStreamException {
  if(closed)
    throw new ClosedDirectoryStreamException();
}
 
源代码21 项目: ParallelGit   文件: GfsDirectoryStream.java
@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();
    }
  };
}
 
源代码22 项目: ParallelGit   文件: GfsDirectoryStream.java
private void checkNotClosed() throws ClosedDirectoryStreamException {
  if(closed)
    throw new ClosedDirectoryStreamException();
}
 
源代码23 项目: jimfs   文件: JimfsSecureDirectoryStream.java
protected synchronized void checkOpen() {
  if (!open) {
    throw new ClosedDirectoryStreamException();
  }
}
 
 类所在包
 类方法
 同包方法