Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JDK 17 jdk.zipfs.jmod - ZIP FS Module
JDK 17 jdk.zipfs.jmod is the JMOD file for JDK 17 ZIP FS module.
JDK 17 ZIP FS module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.zipfs.jmod.
JDK 17 ZIP FS module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 ZIP FS module source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.zipfs.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/nio/zipfs/ByteArrayChannel.java
/* * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package jdk.nio.zipfs; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.NonWritableChannelException; import java.nio.channels.SeekableByteChannel; import java.util.Arrays; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; public class ByteArrayChannel implements SeekableByteChannel { private final ReadWriteLock rwlock = new ReentrantReadWriteLock(); private byte buf[]; /* * The current position of this channel. */ private int pos; /* * The index that is one greater than the last valid byte in the channel. */ private int last; private boolean closed; private boolean readonly; /* * Creates a {@code ByteArrayChannel} with size {@code sz}. */ ByteArrayChannel(int sz, boolean readonly) { this.buf = new byte[sz]; this.pos = this.last = 0; this.readonly = readonly; } /* * Creates a ByteArrayChannel with its 'pos' at 0 and its 'last' at buf's end. * Note: no defensive copy of the 'buf', used directly. */ ByteArrayChannel(byte[] buf, boolean readonly) { this.buf = buf; this.pos = 0; this.last = buf.length; this.readonly = readonly; } @Override public boolean isOpen() { return !closed; } @Override public long position() throws IOException { beginRead(); try { ensureOpen(); return pos; } finally { endRead(); } } @Override public SeekableByteChannel position(long pos) throws IOException { beginWrite(); try { ensureOpen(); if (pos < 0 || pos >= Integer.MAX_VALUE) throw new IllegalArgumentException("Illegal position " + pos); this.pos = Math.min((int)pos, last); return this; } finally { endWrite(); } } @Override public int read(ByteBuffer dst) throws IOException { beginWrite(); try { ensureOpen(); if (pos == last) return -1; int n = Math.min(dst.remaining(), last - pos); dst.put(buf, pos, n); pos += n; return n; } finally { endWrite(); } } @Override public SeekableByteChannel truncate(long size) throws IOException { if (readonly) throw new NonWritableChannelException(); ensureOpen(); throw new UnsupportedOperationException(); } @Override public int write(ByteBuffer src) throws IOException { if (readonly) throw new NonWritableChannelException(); beginWrite(); try { ensureOpen(); int n = src.remaining(); ensureCapacity(pos + n); src.get(buf, pos, n); pos += n; if (pos > last) { last = pos; } return n; } finally { endWrite(); } } @Override public long size() throws IOException { beginRead(); try { ensureOpen(); return last; } finally { endRead(); } } @Override public void close() throws IOException { if (closed) return; beginWrite(); try { closed = true; buf = null; pos = 0; last = 0; } finally { endWrite(); } } /** * Creates a newly allocated byte array. Its size is the current * size of this channel and the valid contents of the buffer * have been copied into it. * * @return the current contents of this channel, as a byte array. */ public byte[] toByteArray() { beginRead(); try { // avoid copy if last == bytes.length? return Arrays.copyOf(buf, last); } finally { endRead(); } } private void ensureOpen() throws IOException { if (closed) throw new ClosedChannelException(); } final void beginWrite() { rwlock.writeLock().lock(); } final void endWrite() { rwlock.writeLock().unlock(); } private final void beginRead() { rwlock.readLock().lock(); } private final void endRead() { rwlock.readLock().unlock(); } private void ensureCapacity(int minCapacity) { // overflow-conscious code if (minCapacity - buf.length > 0) { grow(minCapacity); } } /** * The maximum size of array to allocate. * Some VMs reserve some header words in an array. * Attempts to allocate larger arrays may result in * OutOfMemoryError: Requested array size exceeds VM limit */ private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; /** * Increases the capacity to ensure that it can hold at least the * number of elements specified by the minimum capacity argument. * * @param minCapacity the desired minimum capacity */ private void grow(int minCapacity) { // overflow-conscious code int oldCapacity = buf.length; int newCapacity = oldCapacity << 1; if (newCapacity - minCapacity < 0) newCapacity = minCapacity; if (newCapacity - MAX_ARRAY_SIZE > 0) newCapacity = hugeCapacity(minCapacity); buf = Arrays.copyOf(buf, newCapacity); } private static int hugeCapacity(int minCapacity) { if (minCapacity < 0) // overflow throw new OutOfMemoryError("Required length exceeds implementation limit"); return (minCapacity > MAX_ARRAY_SIZE) ? Integer.MAX_VALUE : MAX_ARRAY_SIZE; } }
⏎ jdk/nio/zipfs/ByteArrayChannel.java
Or download all of them as a single archive file:
File name: jdk.zipfs-17.0.5-src.zip File size: 56454 bytes Release date: 2022-09-13 Download
⇒ FAQ for JDK (Java Development Kit) 17
2022-11-07, 2170👍, 0💬
Popular Posts:
JDK 11 jdk.internal.JVM Stat.jmod is the JMOD file for JDK 11 Internal Jvmstat module. JDK 11 Intern...
Apache Neethi provides general framework for the programmers to use WS Policy. It is compliant with ...
GJT (Giant Java Tree) implementation of XML Pull Parser. JAR File Size and Download Location: File n...
How to read XML document with XML Schema validation from socket connections with the socket\DelayedI...
commons-lang-2.6.jar is the JAR file for Apache Commons Lang 2.6, which provides a host of helper ut...