/[classpath]/classpath/gnu/java/io/Base64InputStream.java
ViewVC logotype

Diff of /classpath/gnu/java/io/Base64InputStream.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by tromey, Fri Apr 23 21:13:20 2004 UTC revision 1.3 by rsdio, Sun Nov 7 20:27:47 2004 UTC
# Line 1  Line 1 
1  /* Base64InputStream.java -- base-64 input stream.  /* Base64InputStream.java -- base-64 input stream.
2     Copyright (C) 2003 Free Software Foundation, Inc.     Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package gnu.java.io;  package gnu.java.io;
40    
41    import java.io.ByteArrayInputStream;
42    import java.io.ByteArrayOutputStream;
43  import java.io.FilterInputStream;  import java.io.FilterInputStream;
44  import java.io.IOException;  import java.io.IOException;
45  import java.io.InputStream;  import java.io.InputStream;
# Line 90  public class Base64InputStream extends F Line 92  public class Base64InputStream extends F
92      eof = false;      eof = false;
93    }    }
94    
95      // Class method.
96      // ------------------------------------------------------------------------
97    
98      /**
99       * Decode a single Base-64 string to a byte array.
100       *
101       * @param base64 The Base-64 encoded data.
102       * @return The decoded bytes.
103       * @throws IOException If the given data do not compose a valid Base-64
104       *  sequence.
105       */
106      public static byte[] decode(String base64) throws IOException
107      {
108        Base64InputStream in =
109          new Base64InputStream(new ByteArrayInputStream(base64.getBytes()));
110        ByteArrayOutputStream out =
111          new ByteArrayOutputStream((int) (base64.length() / 0.666));
112        byte[] buf = new byte[1024];
113        int len;
114        while ((len = in.read(buf)) != -1)
115          out.write(buf, 0, len);
116        return out.toByteArray();
117      }
118    
119    // Instance methods.    // Instance methods.
120    // ------------------------------------------------------------------------    // ------------------------------------------------------------------------
121    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26