thought i'd test from a relatively independent setup [pine+postfix] to
make sure this isn't an ISP/company thing.

On Tue, 11 Mar 2003, Stephen Colebourne wrote:

> It seems .java files are rejected, but .txt and .patch files are accepted.
> Anybody know who controls this?
>
> Stephen
>
> ----- Original Message -----
> From: "Stephen Colebourne" <[EMAIL PROTECTED]>
> To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
> Sent: Sunday, March 09, 2003 12:15 AM
> Subject: [general] Attachments
>
>
> > I've just made a couple of attempts to send attachments to the list
> without
> > success. Others have also tried recently to send attachments and have
> failed
> > (Howard Lewis Ship for example). Has the list configuration been changed
> to
> > reject attachments?? It certainly seems broken.
> >
> > Stephen
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
// ByteArray.java

package com.generationjava.lang;


/**
 * Provides useful methods for manipulating ByteArrays.
 *
 * Todo: Integrate faster byte handling supplied by sclayman.
 *
 * @author [EMAIL PROTECTED]
 * @date   2000-09-25
 */
public class ByteArray {

    private byte[] myBits;

    /**
     * Construct an object to contain an array of bytes.
     *
     * @param b byte[] of values to contain
     */
    public ByteArray(byte[] b) {
        myBits = b;
    }

    /**
     * converts a byte array into a String in hexidecimal form.
     *
     * @param b byte[] to turn to a String
     *
     * @return String of bytes in hexadecimal format
     */
    static public String byteArrayToString(byte[] b) {
        if(b == null) {
            return null;
        }

        StringBuffer ret = new StringBuffer();
        int sz = b.length;

        for(int i=0; i<sz; i++) {
            ret.append( byteToString(b[i]) );
        }

        return ret.toString();
    }
    
    /**
     * given a byte, return a String like:  "09" or "AA" etc..
     *
     * @param b byte to turn to a String
     *
     * @return String of byte in hexadecimal format
     */
    static public String byteToString(byte b) {
        int i = (int)b;
        if(i < 0) {
            i += 256;
        }
        String tmp = Integer.toHexString( i );
        if(tmp.length() == 1) {
            tmp = "0"+tmp;
        }
        return tmp;
    }

    /**
     * given a String like: "09" or "AA" etc, return the relevant byte.
     *
     * @param s String of byte in hexadecimal format
     *
     * @return byte value of hexadecimal-string
     */
    static public byte stringToByte(String s) {
        try {
            return (byte)Integer.parseInt(s,16);
        } catch(NumberFormatException nfe) {
                return 0;
        }
    }

    /**
     * converts a hexidecimal form of String to a byte array.
     *
     * @param s String of bytes in hexadecimal format
     *
     * @return byte[] values of hexadecimal-string
     */
    static public byte[] stringToByteArray(String bstr) {
        if(bstr == null) {
            return null;
        }

        int sz = bstr.length();
        byte[] bytes = new byte[sz/2];

        for(int i=0; i<sz/2; i++) {
            bytes[i] = stringToByte(bstr.substring(2*i,2*i+2));
        }

        return bytes;
    }
    
    /**
     * Flattern an array of longs into an array of byte.
     * The primitive type, 'long' is 8 times the size of 
     * a byte.
     *
     * @param s String of byte in hexadecimal format
     *
     * @return byte value of hexadecimal-string
     */
    static public byte[] longArrayToByteArray(long[] lns) {
        byte[] ret = new byte[lns.length*8];

        for(int i=0; i<lns.length; i++) {
            ret[i*8 + 0] = (byte)((lns[i] >>  0) & 0xFF);
            ret[i*8 + 1] = (byte)((lns[i] >>  8) & 0xFF);
            ret[i*8 + 2] = (byte)((lns[i] >> 16) & 0xFF);
            ret[i*8 + 3] = (byte)((lns[i] >> 24) & 0xFF);
            ret[i*8 + 4] = (byte)((lns[i] >> 32) & 0xFF);
            ret[i*8 + 5] = (byte)((lns[i] >> 40) & 0xFF);
            ret[i*8 + 6] = (byte)((lns[i] >> 48) & 0xFF);
            ret[i*8 + 7] = (byte)((lns[i] >> 56) & 0xFF);
        }
        
        return ret;
    }

}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to