commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 36243] - [compress] TarInputStream returns negative value for read() [PATCH]
Date Mon, 22 Aug 2005 00:29:45 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36243>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36243





------- Additional Comments From ajmp1960@hotmail.com  2005-08-22 02:29 -------
Create a file like this:
 $ perl -e 'print "\xff"' > negative-byte
 $ tar cf negative-byte.tar negative-byte

Then run the following Java program:

import org.apache.commons.compress.tar.TarInputStream;
import org.apache.commons.compress.tar.TarEntry;
import java.io.FileInputStream;

public class TarPlay  {
    public static void main(String[] args) throws Exception {
        TarInputStream tis = new TarInputStream(new
FileInputStream("negative-byte.tar"));
        TarEntry tar = tis.getNextEntry();
        System.out.println("Name: " + tar.getName() + ", size: " + tar.getSize());
        int data = tis.read();
        if (data == -1)
            System.out.println("EOF when trying to read first byte");
        else
            System.out.println("Read first byte: " + data);
    }
}



This will output:
Name: negative-byte, size: 1
EOF when trying to read first byte

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message