Click here to Skip to main content
15,899,013 members
Home / Discussions / Java
   

Java

 
AnswerRe: Parallel processing of two methods in main class Pin
Richard MacCutchan1-Jun-13 4:28
mveRichard MacCutchan1-Jun-13 4:28 
QuestionPut and order values in a List Pin
Ghandil31-May-13 8:36
Ghandil31-May-13 8:36 
AnswerRe: Put and order values in a List Pin
Prasad Khandekar3-Jun-13 3:45
professionalPrasad Khandekar3-Jun-13 3:45 
QuestionCipherInputStream.read(byte[]) Dropping Final Block Pin
Skippums31-May-13 6:40
Skippums31-May-13 6:40 
SuggestionRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
AlphaDeltaTheta31-May-13 21:51
AlphaDeltaTheta31-May-13 21:51 
AnswerRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
AlphaDeltaTheta31-May-13 22:06
AlphaDeltaTheta31-May-13 22:06 
GeneralRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
Skippums3-Jun-13 7:26
Skippums3-Jun-13 7:26 
AnswerRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
Skippums3-Jun-13 7:33
Skippums3-Jun-13 7:33 
For anyone else looking for an answer to this, I couldn't find one. However, I am able to perform the following workaround: Instead of returning a CipherInputStream, I return a CipherInputStreamWrapper, which I define to be the following internal class:
Java
class CipherInputStreamWrapper extends CipherInputStream {

    CipherInputStreamWrapper(final InputStream is, final Cipher cipher) {
        super(is, cipher);
    }

    @Override
    public int read(final byte[] b) {
        return this.read(b, 0, b.length);
    }

    @Override
    public int read(final byte[] b, final int off, final int len) {
        for (int i = 0; i < len; ++i) {
            final int nextByte = this.read();
            if (nextByte < 0) return i;
            b[off + i] = (byte)nextByte;
        }
        return len;
    }
}
The implementation of read(byte[]) is actually identical to that in CipherInputStream in Java 6 and 7, but if the implentation changes in the future, NOT overloading that method would result in yet another erroneous implementation. I am always open to other ideas if anyone else has a cleaner solution!
Sounds like somebody's got a case of the Mondays

-Jeff

SuggestionRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
AlphaDeltaTheta3-Jun-13 17:05
AlphaDeltaTheta3-Jun-13 17:05 
GeneralRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
Skippums4-Jun-13 4:47
Skippums4-Jun-13 4:47 
AnswerRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
AlphaDeltaTheta4-Jun-13 5:30
AlphaDeltaTheta4-Jun-13 5:30 
GeneralRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
Skippums4-Jun-13 6:33
Skippums4-Jun-13 6:33 
AnswerRe: CipherInputStream.read(byte[]) Dropping Final Block Pin
AlphaDeltaTheta4-Jun-13 6:41
AlphaDeltaTheta4-Jun-13 6:41 
QuestionNew in Java Pin
Garde33330-May-13 18:47
Garde33330-May-13 18:47 
QuestionRe: New in Java Pin
AlphaDeltaTheta30-May-13 20:42
AlphaDeltaTheta30-May-13 20:42 
AnswerRe: New in Java Pin
Garde33331-May-13 17:57
Garde33331-May-13 17:57 
AnswerRe: New in Java Pin
dusty_dex30-May-13 20:56
dusty_dex30-May-13 20:56 
AnswerRe: New in Java Pin
Richard MacCutchan30-May-13 21:18
mveRichard MacCutchan30-May-13 21:18 
GeneralRe: New in Java Pin
Garde33331-May-13 17:45
Garde33331-May-13 17:45 
GeneralRe: New in Java Pin
Richard MacCutchan31-May-13 21:41
mveRichard MacCutchan31-May-13 21:41 
GeneralRe: New in Java Pin
Pujara Jignesh2-Jun-13 0:12
Pujara Jignesh2-Jun-13 0:12 
AnswerRe: New in Java Pin
Amarnath S30-May-13 21:43
professionalAmarnath S30-May-13 21:43 
AnswerRe: New in Java Pin
jiyasharma18-Jun-13 1:48
jiyasharma18-Jun-13 1:48 
Questionin jsp Pin
Swamy Kandi30-May-13 2:02
Swamy Kandi30-May-13 2:02 
AnswerRe: in jsp Pin
Richard MacCutchan30-May-13 21:16
mveRichard MacCutchan30-May-13 21:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.