Java Exceptions Catalog - Part 2: I/O, Filesystem & Network
Comprehensive reference guide to standard stream exceptions (java.io), modern file channels/buffers (java.nio), and network/SSL exceptions (java.net & javax.net.ssl).
1. Stream & Serialization Exceptions (java.io Package)
java.io.IOException
Base class for exceptions produced by failed or interrupted I/O operations across streams, files, and sockets.
java.io.FileNotFoundException
Attempting to access a file at a path that does not exist or cannot be opened due to permission restrictions.
Files.exists(path) before opening input streams.java.io.EOFException
Signals that an end of file or end of stream has been reached unexpectedly during an input operation.
java.io.NotSerializableException
Attempting to serialize an object instance that does not implement the java.io.Serializable marker interface.
Serializable on the target class or mark un-serializable fields as transient.java.io.InvalidClassException
Serialization runtime detects a class mismatch, missing serialVersionUID, or restricted access modifiers during deserialization.
private static final long serialVersionUID across versions.java.io.InterruptedIOException
Signals that an I/O operation has been interrupted by another thread.
java.io.StreamCorruptedException
Control information read from an object input stream violates internal consistency checks.
java.io.OptionalDataException
Object read operation failed because primitive data was encountered instead of an object in the stream.
java.io.WriteAbortedException
Reading an object stream interrupted because one of the inner objects threw an exception during writing.
java.io.SyncFailedException
Signaled when a FileDescriptor.sync() system call fails to flush buffers to underlying physical media.
java.io.CharConversionException
An error occurred during character encoding or decoding operations.
java.io.UTFDataFormatException
A malformed modified UTF-8 string was encountered in a data input stream.
java.io.UncheckedIOException
An unchecked wrapper exception around an IOException (commonly thrown during Java Stream API pipelines).
2. Filesystem, Channels & Buffers (java.nio Package)
java.nio.file.FileSystemException
Base class for file system operation failures in the modern NIO.2 API.
java.nio.file.NoSuchFileException
Thrown when an NIO file system operation fails because a target file or directory path does not exist.
Files.exists(path) or Files.createDirectories(path) before executing operations.java.nio.file.AccessDeniedException
File operation fails due to insufficient file permissions or OS access restrictions.
Files.setPosixFilePermissions().java.nio.file.FileAlreadyExistsException
Attempting to create a file or directory at a path that already exists on disk.
java.nio.file.DirectoryNotEmptyException
Attempting to delete a directory that still contains files or subdirectories.
java.nio.file.AtomicMoveNotSupportedException
Attempting an atomic move file operation across different mounted filesystems.
java.nio.channels.ClosedChannelException
Attempting an I/O operation on an NIO Channel that has already been closed.
channel.isOpen() prior to performing read or write calls.java.nio.channels.AsynchronousCloseException
Operation interrupted because another thread closed the underlying channel instance.
java.nio.channels.ClosedByInterruptException
Channel closed automatically because the thread executing the I/O call was interrupted.
java.nio.channels.OverlappingFileLockException
Attempting to acquire a file lock that overlaps an existing lock held by the same JVM instance.
java.nio.channels.NonReadableChannelException
Attempting to read from an NIO channel that was opened without read access permissions.
java.nio.channels.NonWritableChannelException
Attempting to write to an NIO channel that was opened without write access permissions.
java.nio.BufferOverflowException
Writing elements into an NIO Buffer past its defined limit capacity.
java.nio.BufferUnderflowException
Reading elements from an NIO Buffer when fewer elements remain than requested.
java.nio.InvalidMarkException
Attempting to call buffer.reset() without previously defining a valid mark position.
java.nio.ReadOnlyBufferException
Invoking mutation methods (like `put()`) on a read-only NIO Buffer.
3. Networking, Sockets & SSL (java.net & javax.net.ssl Package)
java.net.SocketException
Base class for underlying TCP/UDP socket creation or protocol transmission errors.
java.net.ConnectException
Connection refused by remote host on specified address/port (service down or port closed).
java.net.SocketTimeoutException
A timeout occurred on socket read or connect before receiving data from remote host.
socket.setSoTimeout(ms) or optimize remote server latency.java.net.UnknownHostException
The IP address of a host could not be resolved by DNS or local network lookups.
java.net.BindException
Attempting to bind a socket to a local address/port that is already in use by another process.
java.net.NoRouteToHostException
Remote host unreachable due to intermediate router issues or local network/firewall blocks.
java.net.PortUnreachableException
An ICMP Port Unreachable message was received on a connected UDP socket.
java.net.MalformedURLException
A URL string could not be parsed because no valid protocol was specified or the string format is corrupt.
java.net.URISyntaxException
Checked exception indicating that a string could not be parsed as a URI reference.
java.net.ProtocolException
An error occurred in the underlying protocol (e.g., HTTP protocol error).
java.net.HttpRetryException
An HTTP request cannot be retried automatically due to streaming mode restrictions.
javax.net.ssl.SSLException
Base class for errors encountered during SSL/TLS negotiation or secure communication.
javax.net.ssl.SSLHandshakeException
TLS handshake failed due to untrusted certificates, expired certificates, or cipher protocol mismatch.
javax.net.ssl.SSLPeerUnverifiedException
Indicates that the remote peer's identity has not been verified during SSL session setup.
javax.net.ssl.SSLProtocolException
Indicates an error in the operation of the SSL protocol implementation.
No comments:
Post a Comment