private Base64()
    {
    }    public static void main(String args[])
    {
        String s = "Hello, world";
        s = "abcd";
        byte abyte0[] = encodeString(s).getBytes();
        byte abyte1[] = decode(abyte0, 0, abyte0.length);
        System.out.println("\n\n" + s + ":" + new String(abyte0) + ":" + new String(abyte1));
        try
        {
            FileInputStream fileinputstream = new FileInputStream("c:\\abcd.txt");
            InputStream inputstream = new InputStream(fileinputstream, false);
            for(int i = 0; (i = inputstream.read()) > 0;);
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }    private static byte[] encode3to4(byte abyte0[])
    {
        return encode3to4(abyte0, 3);
    }    private static byte[] encode3to4(byte abyte0[], int i)
    {
        byte abyte1[] = new byte[4];
        encode3to4(abyte0, 0, i, abyte1, 0);
        return abyte1;
    }    private static byte[] encode3to4(byte abyte0[], int i, int j, byte abyte1[], int k)
    {
        int l = (j <= 0 ? 0 : (abyte0[i] << 24) >>> 8) | (j <= 1 ? 0 : (abyte0[i + 1] << 24) >>> 16) | (j <= 2 ? 0 : (abyte0[i + 2] << 24) >>> 24);
        switch(j)
        {
        case 3: // '\003'
            abyte1[k] = ALPHABET[l >>> 18];
            abyte1[k + 1] = ALPHABET[l >>> 12 & 0x3f];
            abyte1[k + 2] = ALPHABET[l >>> 6 & 0x3f];
            abyte1[k + 3] = ALPHABET[l & 0x3f];
            return abyte1;        case 2: // '\002'
            abyte1[k] = ALPHABET[l >>> 18];
            abyte1[k + 1] = ALPHABET[l >>> 12 & 0x3f];
            abyte1[k + 2] = ALPHABET[l >>> 6 & 0x3f];
            abyte1[k + 3] = 61;
            return abyte1;        case 1: // '\001'
            abyte1[k] = ALPHABET[l >>> 18];
            abyte1[k + 1] = ALPHABET[l >>> 12 & 0x3f];
            abyte1[k + 2] = 61;
            abyte1[k + 3] = 61;
            return abyte1;
        }
        return abyte1;
    }    public static String encodeObject(Serializable serializable)
    {
        ByteArrayOutputStream bytearrayoutputstream;
        OutputStream outputstream;
        ObjectOutputStream objectoutputstream;
        bytearrayoutputstream = null;
        outputstream = null;
        objectoutputstream = null;
        IOException ioexception;
        String s;
        try
        {
            bytearrayoutputstream = new ByteArrayOutputStream();
            outputstream = new OutputStream(bytearrayoutputstream,true);
            objectoutputstream = new ObjectOutputStream(outputstream);
            objectoutputstream.writeObject(serializable);
        }
        finally
        {
            try
            {
                objectoutputstream.close();
            }
            catch(Exception exception1) { }
            try
            {
                outputstream.close();
            }
            catch(Exception exception2) { }
            try
            {
                bytearrayoutputstream.close();
            }
            catch(Exception exception3) { }
        }
        //break MISSING_BLOCK_LABEL_99;
        //ioexception;
        ioexception.printStackTrace();
        s = null;
        return s;
        return new String(bytearrayoutputstream.toByteArray());
    }

解决方案 »

  1.   

    public static String encodeBytes(byte abyte0[])
        {
            return encodeBytes(abyte0, 0, abyte0.length);
        }    public static String encodeBytes(byte abyte0[], int i, int j)
        {
            int k = (j * 4) / 3;
            byte abyte1[] = new byte[k + (j % 3 <= 0 ? 0 : 4) + k / 76];
            int l = 0;
            int i1 = 0;
            int j1 = j - 2;
            int k1 = 0;
            while(l < j1)
            {
                encode3to4(abyte0, l, 3, abyte1, i1);
                if((k1 += 4) == 76)
                {
                    abyte1[i1 + 4] = 10;
                    i1++;
                    k1 = 0;
                }
                l += 3;
                i1 += 4;
            }
            if(l < j)
            {
                encode3to4(abyte0, l, j - l, abyte1, i1);
                i1 += 4;
            }
            return new String(abyte1, 0, i1);
        }    public static String encodeString(String s)
        {
            return encodeBytes(s.getBytes());
        }    private static byte[] decode4to3(byte abyte0[])
        {
            byte abyte1[] = new byte[3];
            int i = decode4to3(abyte0, 0, abyte1, 0);
            byte abyte2[] = new byte[i];
            for(int j = 0; j < i; j++)
                abyte2[j] = abyte1[j];        return abyte2;
        }    private static int decode4to3(byte abyte0[], int i, byte abyte1[], int j)
        {
            if(abyte0[i + 2] == 61)
            {
                int k = (DECODABET[abyte0[i]] << 24) >>> 6 | (DECODABET[abyte0[i + 1]] << 24) >>> 12;
                abyte1[j] = (byte)(k >>> 16);
                return 1;
            }
            if(abyte0[i + 3] == 61)
            {
                int l = (DECODABET[abyte0[i]] << 24) >>> 6 | (DECODABET[abyte0[i + 1]] << 24) >>> 12 | (DECODABET[abyte0[i + 2]] << 24) >>> 18;
                abyte1[j] = (byte)(l >>> 16);
                abyte1[j + 1] = (byte)(l >>> 8);
                return 2;
            } else
            {
                int i1 = (DECODABET[abyte0[i]] << 24) >>> 6 | (DECODABET[abyte0[i + 1]] << 24) >>> 12 | (DECODABET[abyte0[i + 2]] << 24) >>> 18 | (DECODABET[abyte0[i + 3]] << 24) >>> 24;
                abyte1[j] = (byte)(i1 >> 16);
                abyte1[j + 1] = (byte)(i1 >> 8);
                abyte1[j + 2] = (byte)i1;
                return 3;
            }
        }    public static byte[] decode(String s)
        {
            byte abyte0[] = s.getBytes();
            return decode(abyte0, 0, abyte0.length);
        }    public static String decodeToString(String s)
        {
            return new String(decode(s));
        }    public static Object decodeToObject(String s)
        {
            byte abyte0[];
            ByteArrayInputStream bytearrayinputstream;
            ObjectInputStream objectinputstream;
            abyte0 = decode(s);
            bytearrayinputstream = null;
            objectinputstream = null;
            Object obj;
            bytearrayinputstream = new ByteArrayInputStream(abyte0);
            objectinputstream = new ObjectInputStream(bytearrayinputstream);
            obj = objectinputstream.readObject();
            try
            {
                bytearrayinputstream.close();
            }
            catch(Exception exception) { }
            try
            {
                objectinputstream.close();
            }
            catch(Exception exception1) { }
            return obj;
            Object obj1;
            //obj1;
            Object obj2;
            ((IOException) (obj1)).printStackTrace();
            obj2 = null;
            try
            {
                bytearrayinputstream.close();
            }
            catch(Exception exception2) { }
            try
            {
                objectinputstream.close();
            }
            catch(Exception exception3) { }
            return obj2;
            //obj1;
            ((ClassNotFoundException) (obj1)).printStackTrace();
            obj2 = null;
            try
            {
                bytearrayinputstream.close();
            }
            catch(Exception exception4) { }
            try
            {
                objectinputstream.close();
            }
            catch(Exception exception5) { }
            return obj2;
            Exception exception6;
            //exception6;
            try
            {
                bytearrayinputstream.close();
            }
            catch(Exception exception7) { }
            try
            {
                objectinputstream.close();
            }
            catch(Exception exception8) { }
            throw exception6;
        }    public static byte[] decode(byte abyte0[], int i, int j)
        {
            int k = (j * 3) / 4;
            byte abyte1[] = new byte[k];
            int l = 0;
            byte abyte2[] = new byte[4];
            int i1 = 0;
            boolean flag = false;
            boolean flag1 = false;
            boolean flag2 = false;
            for(int j1 = 0; j1 < j; j1++)
            {
                byte byte0 = (byte)(abyte0[j1] & 0x7f);
                byte byte1 = DECODABET[byte0];
                if(byte1 >= -5)
                {
                    if(byte1 < -1)
                        continue;
                    abyte2[i1++] = byte0;
                    if(i1 <= 3)
                        continue;
                    l += decode4to3(abyte2, 0, abyte1, l);
                    i1 = 0;
                    if(byte0 == 61)
                        break;
                } else
                {
                    System.err.println("Bad Base64 input character at " + j1 + ": " + abyte0[j1] + "(decimal)");
                    return null;
                }
            }        byte abyte3[] = new byte[l];
            System.arraycopy(abyte1, 0, abyte3, 0, l);
            return abyte3;
        }
    }
      

  2.   

    outputstream = new OutputStream(bytearrayoutputstream,true);
    改为:outputstream = new com.Base64.OutputStream(bytearrayoutputstream,true);
      

  3.   

    同楼上,你没有import com.Base64.OutputStream;
    所以到这里认不出来OutputStream
      

  4.   

    老兄,你好歹也看一下错误提示啊!
    把你的OutputStream改个名,这个错误就没有了