Ajouter un commentaire

thesuixx

c'est la methode read(byte[] b) que j'utilise: la preuve:

final byte[] buf = new byte[8192]; 

le contenu du fichier est bien ecrit dans l'objet de type myinputStream.
le probleme, c'est qu'il semble que le premier octet de mon image jpeg dans l'archive soit -1

(quand je print le contenu du tableau de byte de mon objet de type myInputStream, j'ai un -1 au debut)

or, la valeur -1 sert de sentinelle

public abstract int read()
                  throws IOException

    Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

    A subclass must provide an implementation of this method.

    Returns:
        the next byte of data, or -1 if the end of the stream is reached. 
    Throws:
        IOException - if an I/O error occurs.

Et je pense que la methode ImageIO.read(Inputstream ins) appelle la methode ins.read(), donc quand ins.read retourne -1, imageIo.read(Inputstream ins) considere avoir atteint la fin de l'image et arrete la lecture.

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 RRRR   Y   Y  DDD    QQQ    V     V 
R R Y Y D D Q Q V V
RRRR Y D D Q Q V V
R R Y D D Q QQ V V
R RR Y DDD QQQQ V
Q