Develop an open() method within the BucketBase class that returns a stream-like object, replicating core functionality of Java's InputStream and OutputStream for interacting with objects in a bucket-based storage system.
Functional Requirements:
- Object Access: The method must accept a parameter that uniquely identifies the object within the bucket (e.g., object key or path).
- Modes: Implement support for both read and write modes, returning appropriate stream objects.
- Stream-Like Objects:
- Read Mode: Return an InputStream or a derived class that supports read(), read(byte[]), skip(), and close() methods.
- Write Mode: Return an OutputStream or a derived class that supports write(int), write(byte[]), flush(), and close() methods. skip() is not supported in write mode.
- Binary and Text Modes: Support both binary and text modes, handling encoding/decoding as necessary using appropriate Reader/Writer classes.
- Buffered Operations: Implement buffered read/write operations for efficiency, utilizing flush() to commit writes.
- Error Handling: Implement appropriate error handling for scenarios such as:
- Object not found.
- Insufficient permissions.
- Invalid mode.
- Connection errors.
Acceptance Criteria:
- The open() method must return appropriate stream objects for read and write modes.
- Appropriate exceptions must be thrown for error conditions.
- The code must follow Java coding conventions and best practices.
Develop an
open()method within the BucketBase class that returns a stream-like object, replicating core functionality of Java'sInputStreamandOutputStreamfor interacting with objects in a bucket-based storage system.Functional Requirements:
Acceptance Criteria: