hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [46/51] [partial] hbase-site git commit: Published site at cadfb21f4bb465d1e305db2a159b8574282c8150.
Date Wed, 23 Mar 2016 15:18:28 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/123539c5/apidocs/src-html/org/apache/hadoop/hbase/util/Base64.Base64OutputStream.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/util/Base64.Base64OutputStream.html b/apidocs/src-html/org/apache/hadoop/hbase/util/Base64.Base64OutputStream.html
index d62c219..e434efc 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/util/Base64.Base64OutputStream.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/util/Base64.Base64OutputStream.html
@@ -1100,564 +1100,599 @@
 <span class="sourceLineNo">1092</span>   */<a name="line.1092"></a>
 <span class="sourceLineNo">1093</span>  public static byte[] decodeFromFile(String filename) {<a name="line.1093"></a>
 <span class="sourceLineNo">1094</span>    byte[] decodedData = null;<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>    Base64InputStream bis = null;<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span>    try {<a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>      File file = new File(filename);<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>      byte[] buffer;<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span><a name="line.1099"></a>
-<span class="sourceLineNo">1100</span>      // Check the size of file<a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>      if (file.length() &gt; Integer.MAX_VALUE) {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>        LOG.fatal("File is too big for this convenience method (" +<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>            file.length() + " bytes).");<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>        return null;<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>      } // end if: file too big for int index<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span><a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>      buffer = new byte[(int) file.length()];<a name="line.1107"></a>
+<span class="sourceLineNo">1095</span>    BufferedInputStream bufferedInputStream = null;<a name="line.1095"></a>
+<span class="sourceLineNo">1096</span>    FileInputStream fileInputStream = null;<a name="line.1096"></a>
+<span class="sourceLineNo">1097</span>    Base64InputStream base64InputStream = null;<a name="line.1097"></a>
+<span class="sourceLineNo">1098</span>    try {<a name="line.1098"></a>
+<span class="sourceLineNo">1099</span>      File file = new File(filename);<a name="line.1099"></a>
+<span class="sourceLineNo">1100</span>      byte[] buffer;<a name="line.1100"></a>
+<span class="sourceLineNo">1101</span><a name="line.1101"></a>
+<span class="sourceLineNo">1102</span>      // Check the size of file<a name="line.1102"></a>
+<span class="sourceLineNo">1103</span>      if (file.length() &gt; Integer.MAX_VALUE) {<a name="line.1103"></a>
+<span class="sourceLineNo">1104</span>        LOG.fatal("File is too big for this convenience method (" +<a name="line.1104"></a>
+<span class="sourceLineNo">1105</span>            file.length() + " bytes).");<a name="line.1105"></a>
+<span class="sourceLineNo">1106</span>        return null;<a name="line.1106"></a>
+<span class="sourceLineNo">1107</span>      } // end if: file too big for int index<a name="line.1107"></a>
 <span class="sourceLineNo">1108</span><a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>      // Open a stream<a name="line.1109"></a>
+<span class="sourceLineNo">1109</span>      buffer = new byte[(int) file.length()];<a name="line.1109"></a>
 <span class="sourceLineNo">1110</span><a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>      bis = new Base64InputStream(new BufferedInputStream(<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>          new FileInputStream(file)), DECODE);<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span><a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>      // Read until done<a name="line.1114"></a>
+<span class="sourceLineNo">1111</span>      // Open a stream<a name="line.1111"></a>
+<span class="sourceLineNo">1112</span>      fileInputStream = new FileInputStream(file);<a name="line.1112"></a>
+<span class="sourceLineNo">1113</span>      bufferedInputStream = new BufferedInputStream(fileInputStream);<a name="line.1113"></a>
+<span class="sourceLineNo">1114</span>      base64InputStream = new Base64InputStream(bufferedInputStream, DECODE);<a name="line.1114"></a>
 <span class="sourceLineNo">1115</span><a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>      int length = 0;<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>      for (int numBytes; (numBytes = bis.read(buffer, length, 4096)) &gt;= 0; ) {<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>        length += numBytes;<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>      }<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span><a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>      // Save in a variable to return<a name="line.1121"></a>
+<span class="sourceLineNo">1116</span>      // Read until done<a name="line.1116"></a>
+<span class="sourceLineNo">1117</span><a name="line.1117"></a>
+<span class="sourceLineNo">1118</span>      int length = 0;<a name="line.1118"></a>
+<span class="sourceLineNo">1119</span>      for (int numBytes; (numBytes = base64InputStream.read(buffer, length, 4096)) &gt;= 0; ) {<a name="line.1119"></a>
+<span class="sourceLineNo">1120</span>        length += numBytes;<a name="line.1120"></a>
+<span class="sourceLineNo">1121</span>      }<a name="line.1121"></a>
 <span class="sourceLineNo">1122</span><a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>      decodedData = new byte[length];<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>      System.arraycopy(buffer, 0, decodedData, 0, length);<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span><a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>    } catch (IOException e) {<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>      LOG.error("Error decoding from file " + filename, e);<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span><a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    } finally {<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>      if (bis != null) {<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>        try {<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>          bis.close();<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>        } catch (Exception e) {<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span>          LOG.error("error closing Base64InputStream", e);<a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>        }<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>      }<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>    } // end finally<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span><a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>    return decodedData;<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>  } // end decodeFromFile<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span><a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>  /**<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>   * Convenience method for reading a binary file and base64-encoding it.<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>   *<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>   * @param filename Filename for reading binary data<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>   * @return base64-encoded string or null if unsuccessful<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span>   *<a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>   * @since 2.1<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>   */<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>  public static String encodeFromFile(String filename) {<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>    String encodedData = null;<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>    Base64InputStream bis = null;<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>    try {<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>      File file = new File(filename);<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span><a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>      // Need max() for math on small files (v2.2.1)<a name="line.1156"></a>
+<span class="sourceLineNo">1123</span>      // Save in a variable to return<a name="line.1123"></a>
+<span class="sourceLineNo">1124</span><a name="line.1124"></a>
+<span class="sourceLineNo">1125</span>      decodedData = new byte[length];<a name="line.1125"></a>
+<span class="sourceLineNo">1126</span>      System.arraycopy(buffer, 0, decodedData, 0, length);<a name="line.1126"></a>
+<span class="sourceLineNo">1127</span><a name="line.1127"></a>
+<span class="sourceLineNo">1128</span>    } catch (IOException e) {<a name="line.1128"></a>
+<span class="sourceLineNo">1129</span>      LOG.error("Error decoding from file " + filename, e);<a name="line.1129"></a>
+<span class="sourceLineNo">1130</span><a name="line.1130"></a>
+<span class="sourceLineNo">1131</span>    } finally {<a name="line.1131"></a>
+<span class="sourceLineNo">1132</span>      if (fileInputStream != null) {<a name="line.1132"></a>
+<span class="sourceLineNo">1133</span>        try {<a name="line.1133"></a>
+<span class="sourceLineNo">1134</span>          fileInputStream.close();<a name="line.1134"></a>
+<span class="sourceLineNo">1135</span>        } catch (Exception e) {<a name="line.1135"></a>
+<span class="sourceLineNo">1136</span>          LOG.error("error closing FileInputStream", e);<a name="line.1136"></a>
+<span class="sourceLineNo">1137</span>        }<a name="line.1137"></a>
+<span class="sourceLineNo">1138</span>      }<a name="line.1138"></a>
+<span class="sourceLineNo">1139</span>      if (bufferedInputStream != null) {<a name="line.1139"></a>
+<span class="sourceLineNo">1140</span>        try {<a name="line.1140"></a>
+<span class="sourceLineNo">1141</span>          bufferedInputStream.close();<a name="line.1141"></a>
+<span class="sourceLineNo">1142</span>        } catch (Exception e) {<a name="line.1142"></a>
+<span class="sourceLineNo">1143</span>          LOG.error("error closing BufferedInputStream", e);<a name="line.1143"></a>
+<span class="sourceLineNo">1144</span>        }<a name="line.1144"></a>
+<span class="sourceLineNo">1145</span>      }<a name="line.1145"></a>
+<span class="sourceLineNo">1146</span>      if (base64InputStream != null) {<a name="line.1146"></a>
+<span class="sourceLineNo">1147</span>        try {<a name="line.1147"></a>
+<span class="sourceLineNo">1148</span>          base64InputStream.close();<a name="line.1148"></a>
+<span class="sourceLineNo">1149</span>        } catch (Exception e) {<a name="line.1149"></a>
+<span class="sourceLineNo">1150</span>          LOG.error("error closing Base64InputStream", e);<a name="line.1150"></a>
+<span class="sourceLineNo">1151</span>        }<a name="line.1151"></a>
+<span class="sourceLineNo">1152</span>      }<a name="line.1152"></a>
+<span class="sourceLineNo">1153</span>    } // end finally<a name="line.1153"></a>
+<span class="sourceLineNo">1154</span><a name="line.1154"></a>
+<span class="sourceLineNo">1155</span>    return decodedData;<a name="line.1155"></a>
+<span class="sourceLineNo">1156</span>  } // end decodeFromFile<a name="line.1156"></a>
 <span class="sourceLineNo">1157</span><a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>      byte[] buffer = new byte[Math.max((int) (file.length() * 1.4), 40)];<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span><a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>      // Open a stream<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span><a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>      bis = new Base64InputStream(new BufferedInputStream(<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>              new FileInputStream(file)), ENCODE);<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span><a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>      // Read until done<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>      int length = 0;<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>      for (int numBytes; (numBytes = bis.read(buffer, length, 4096)) &gt;= 0; ) {<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span>        length += numBytes;<a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>      }<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span><a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>      // Save in a variable to return<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span><a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>      encodedData = new String(buffer, 0, length, PREFERRED_ENCODING);<a name="line.1173"></a>
+<span class="sourceLineNo">1158</span>  /**<a name="line.1158"></a>
+<span class="sourceLineNo">1159</span>   * Convenience method for reading a binary file and base64-encoding it.<a name="line.1159"></a>
+<span class="sourceLineNo">1160</span>   *<a name="line.1160"></a>
+<span class="sourceLineNo">1161</span>   * @param filename Filename for reading binary data<a name="line.1161"></a>
+<span class="sourceLineNo">1162</span>   * @return base64-encoded string or null if unsuccessful<a name="line.1162"></a>
+<span class="sourceLineNo">1163</span>   *<a name="line.1163"></a>
+<span class="sourceLineNo">1164</span>   * @since 2.1<a name="line.1164"></a>
+<span class="sourceLineNo">1165</span>   */<a name="line.1165"></a>
+<span class="sourceLineNo">1166</span>  public static String encodeFromFile(String filename) {<a name="line.1166"></a>
+<span class="sourceLineNo">1167</span>    String encodedData = null;<a name="line.1167"></a>
+<span class="sourceLineNo">1168</span>    FileInputStream fileInputStream = null;<a name="line.1168"></a>
+<span class="sourceLineNo">1169</span>    BufferedInputStream bufferedInputStream = null;<a name="line.1169"></a>
+<span class="sourceLineNo">1170</span>    Base64InputStream base64InputStream = null;<a name="line.1170"></a>
+<span class="sourceLineNo">1171</span><a name="line.1171"></a>
+<span class="sourceLineNo">1172</span>    try {<a name="line.1172"></a>
+<span class="sourceLineNo">1173</span>      File file = new File(filename);<a name="line.1173"></a>
 <span class="sourceLineNo">1174</span><a name="line.1174"></a>
-<span class="sourceLineNo">1175</span>    } catch (IOException e) {<a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>      LOG.error("Error encoding from file " + filename, e);<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span><a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>    } finally {<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>      if (bis != null) {<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>        try {<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>          bis.close();<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>        } catch (Exception e) {<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>          LOG.error("error closing Base64InputStream", e);<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>        }<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>      }<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>    } // end finally<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span><a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>    return encodedData;<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>  } // end encodeFromFile<a name="line.1189"></a>
+<span class="sourceLineNo">1175</span>      // Need max() for math on small files (v2.2.1)<a name="line.1175"></a>
+<span class="sourceLineNo">1176</span><a name="line.1176"></a>
+<span class="sourceLineNo">1177</span>      byte[] buffer = new byte[Math.max((int) (file.length() * 1.4), 40)];<a name="line.1177"></a>
+<span class="sourceLineNo">1178</span><a name="line.1178"></a>
+<span class="sourceLineNo">1179</span>      // Open a stream<a name="line.1179"></a>
+<span class="sourceLineNo">1180</span><a name="line.1180"></a>
+<span class="sourceLineNo">1181</span>      fileInputStream = new FileInputStream(file);<a name="line.1181"></a>
+<span class="sourceLineNo">1182</span>      bufferedInputStream = new BufferedInputStream(fileInputStream);<a name="line.1182"></a>
+<span class="sourceLineNo">1183</span>      base64InputStream = new Base64InputStream(bufferedInputStream, ENCODE);<a name="line.1183"></a>
+<span class="sourceLineNo">1184</span><a name="line.1184"></a>
+<span class="sourceLineNo">1185</span>      // Read until done<a name="line.1185"></a>
+<span class="sourceLineNo">1186</span>      int length = 0;<a name="line.1186"></a>
+<span class="sourceLineNo">1187</span>      for (int numBytes; (numBytes = base64InputStream.read(buffer, length, 4096)) &gt;= 0; ) {<a name="line.1187"></a>
+<span class="sourceLineNo">1188</span>        length += numBytes;<a name="line.1188"></a>
+<span class="sourceLineNo">1189</span>      }<a name="line.1189"></a>
 <span class="sourceLineNo">1190</span><a name="line.1190"></a>
-<span class="sourceLineNo">1191</span>  /**<a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>   * Reads &lt;tt&gt;infile&lt;/tt&gt; and encodes it to &lt;tt&gt;outfile&lt;/tt&gt;.<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>   *<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>   * @param infile Input file<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>   * @param outfile Output file<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>   * @since 2.2<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>   */<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>  public static void encodeFileToFile(String infile, String outfile) {<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>    String encoded = encodeFromFile(infile);<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>    OutputStream out = null;<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>    try {<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>      out = new BufferedOutputStream(new FileOutputStream(outfile));<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>      out.write(encoded.getBytes("US-ASCII")); // Strict, 7-bit output.<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span><a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>    } catch (IOException e) {<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>      LOG.error("error encoding from file " + infile + " to " + outfile, e);<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span><a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>    } finally {<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>      if (out != null) {<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>        try {<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>          out.close();<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>        } catch (Exception e) {<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>          LOG.error("error closing " + outfile, e);<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>        }<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>      }<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>    } // end finally<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>  } // end encodeFileToFile<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span><a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>  /**<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>   * Reads &lt;tt&gt;infile&lt;/tt&gt; and decodes it to &lt;tt&gt;outfile&lt;/tt&gt;.<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>   *<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>   * @param infile Input file<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>   * @param outfile Output file<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span>   * @since 2.2<a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>   */<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>  public static void decodeFileToFile(String infile, String outfile) {<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    byte[] decoded = decodeFromFile(infile);<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>    OutputStream out = null;<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>    try {<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span>      out = new BufferedOutputStream(new FileOutputStream(outfile));<a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>      out.write(decoded);<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span><a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>    } catch (IOException e) {<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span>      LOG.error("error decoding from file " + infile + " to " + outfile, e);<a name="line.1234"></a>
-<span class="sourceLineNo">1235</span><a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>    } finally {<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>      if (out != null) {<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>        try {<a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>          out.close();<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>        } catch (Exception e) {<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>          LOG.error("error closing " + outfile, e);<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>        }<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>      }<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>    } // end finally<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>  } // end decodeFileToFile<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span><a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>  /* ******** I N N E R   C L A S S   I N P U T S T R E A M ******** */<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span><a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>  /**<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>   * A {@link Base64.Base64InputStream} will read data from another<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span>   * &lt;tt&gt;InputStream&lt;/tt&gt;, given in the constructor, and<a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>   * encode/decode to/from Base64 notation on the fly.<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>   *<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>   * @see Base64<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>   * @since 1.3<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span>   */<a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>  @InterfaceAudience.Public<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>  @InterfaceStability.Stable<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>  public static class Base64InputStream extends FilterInputStream {<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span>    private boolean encode;                     // Encoding or decoding<a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>    private int position;                       // Current position in the buffer<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>    private byte[] buffer;                      // Buffer holding converted data<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>    private int bufferLength;                   // Length of buffer (3 or 4)<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>    private int numSigBytes;                    // Meaningful bytes in the buffer<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>    private int lineLength;<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>    private boolean breakLines;                 // Break lines at &lt; 80 characters<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>    private int options;                        // Record options<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>    private byte[] decodabet;                   // Local copy avoids method calls<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span><a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>    /**<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>     * Constructs a {@link Base64InputStream} in DECODE mode.<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span>     *<a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>     * @param in the &lt;tt&gt;InputStream&lt;/tt&gt; from which to read data.<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>     * @since 1.3<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>     */<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>    public Base64InputStream(InputStream in) {<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>      this(in, DECODE);<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>    } // end constructor<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span><a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>    /**<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>     * Constructs a {@link Base64.Base64InputStream} in either ENCODE or DECODE mode.<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>     * &lt;p&gt;<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>     * Valid options:<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>     *<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>     * &lt;pre&gt;<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>     *   ENCODE or DECODE: Encode or Decode as data is read.<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>     *   DONT_BREAK_LINES: don't break lines at 76 characters<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span>     *     (only meaningful when encoding)<a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>     *     &amp;lt;i&amp;gt;Note: Technically, this makes your encoding non-compliant.&amp;lt;/i&amp;gt;<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>     * &lt;/pre&gt;<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>     *<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>     * &lt;p&gt;<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>     * Example: &lt;code&gt;new Base64.Base64InputStream( in, Base64.DECODE )&lt;/code&gt;<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>     *<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>     *<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>     * @param in the &lt;tt&gt;InputStream&lt;/tt&gt; from which to read data.<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>     * @param options Specified options<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>     * @see Base64#ENCODE<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>     * @see Base64#DECODE<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>     * @see Base64#DONT_BREAK_LINES<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>     * @since 2.0<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>     */<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>    public Base64InputStream(InputStream in, int options) {<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>      super(in);<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>      this.breakLines = (options &amp; DONT_BREAK_LINES) != DONT_BREAK_LINES;<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span>      this.encode = (options &amp; ENCODE) == ENCODE;<a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>      this.bufferLength = encode ? 4 : 3;<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>      this.buffer = new byte[bufferLength];<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>      this.position = -1;<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>      this.lineLength = 0;<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>      this.options = options; // Record for later, mostly to determine which<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>                              // alphabet to use<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>      this.decodabet = getDecodabet(options);<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>    } // end constructor<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span><a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>    /**<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>     * Reads enough of the input stream to convert to/from Base64 and returns<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>     * the next byte.<a name="line.1318"></a>
+<span class="sourceLineNo">1191</span>      // Save in a variable to return<a name="line.1191"></a>
+<span class="sourceLineNo">1192</span><a name="line.1192"></a>
+<span class="sourceLineNo">1193</span>      encodedData = new String(buffer, 0, length, PREFERRED_ENCODING);<a name="line.1193"></a>
+<span class="sourceLineNo">1194</span><a name="line.1194"></a>
+<span class="sourceLineNo">1195</span>    } catch (IOException e) {<a name="line.1195"></a>
+<span class="sourceLineNo">1196</span>      LOG.error("Error encoding from file " + filename, e);<a name="line.1196"></a>
+<span class="sourceLineNo">1197</span><a name="line.1197"></a>
+<span class="sourceLineNo">1198</span>    } finally {<a name="line.1198"></a>
+<span class="sourceLineNo">1199</span>      // Can't leak exceptions but still need to clean things up.<a name="line.1199"></a>
+<span class="sourceLineNo">1200</span>      if (fileInputStream != null) {<a name="line.1200"></a>
+<span class="sourceLineNo">1201</span>        try {<a name="line.1201"></a>
+<span class="sourceLineNo">1202</span>          fileInputStream.close();<a name="line.1202"></a>
+<span class="sourceLineNo">1203</span>        } catch (Exception e) {<a name="line.1203"></a>
+<span class="sourceLineNo">1204</span>          LOG.error("error closing FileInputStream", e);<a name="line.1204"></a>
+<span class="sourceLineNo">1205</span>        }<a name="line.1205"></a>
+<span class="sourceLineNo">1206</span>      }<a name="line.1206"></a>
+<span class="sourceLineNo">1207</span>      if (bufferedInputStream != null) {<a name="line.1207"></a>
+<span class="sourceLineNo">1208</span>        try {<a name="line.1208"></a>
+<span class="sourceLineNo">1209</span>          bufferedInputStream.close();<a name="line.1209"></a>
+<span class="sourceLineNo">1210</span>        } catch (Exception e) {<a name="line.1210"></a>
+<span class="sourceLineNo">1211</span>          LOG.error("error closing BufferedInputStream", e);<a name="line.1211"></a>
+<span class="sourceLineNo">1212</span>        }<a name="line.1212"></a>
+<span class="sourceLineNo">1213</span>      }<a name="line.1213"></a>
+<span class="sourceLineNo">1214</span>      if (base64InputStream != null) {<a name="line.1214"></a>
+<span class="sourceLineNo">1215</span>        try {<a name="line.1215"></a>
+<span class="sourceLineNo">1216</span>          base64InputStream.close();<a name="line.1216"></a>
+<span class="sourceLineNo">1217</span>        } catch (Exception e) {<a name="line.1217"></a>
+<span class="sourceLineNo">1218</span>          LOG.error("error closing Base64InputStream", e);<a name="line.1218"></a>
+<span class="sourceLineNo">1219</span>        }<a name="line.1219"></a>
+<span class="sourceLineNo">1220</span>      }<a name="line.1220"></a>
+<span class="sourceLineNo">1221</span>    } // end finally<a name="line.1221"></a>
+<span class="sourceLineNo">1222</span><a name="line.1222"></a>
+<span class="sourceLineNo">1223</span>    return encodedData;<a name="line.1223"></a>
+<span class="sourceLineNo">1224</span>  } // end encodeFromFile<a name="line.1224"></a>
+<span class="sourceLineNo">1225</span><a name="line.1225"></a>
+<span class="sourceLineNo">1226</span>  /**<a name="line.1226"></a>
+<span class="sourceLineNo">1227</span>   * Reads &lt;tt&gt;infile&lt;/tt&gt; and encodes it to &lt;tt&gt;outfile&lt;/tt&gt;.<a name="line.1227"></a>
+<span class="sourceLineNo">1228</span>   *<a name="line.1228"></a>
+<span class="sourceLineNo">1229</span>   * @param infile Input file<a name="line.1229"></a>
+<span class="sourceLineNo">1230</span>   * @param outfile Output file<a name="line.1230"></a>
+<span class="sourceLineNo">1231</span>   * @since 2.2<a name="line.1231"></a>
+<span class="sourceLineNo">1232</span>   */<a name="line.1232"></a>
+<span class="sourceLineNo">1233</span>  public static void encodeFileToFile(String infile, String outfile) {<a name="line.1233"></a>
+<span class="sourceLineNo">1234</span>    String encoded = encodeFromFile(infile);<a name="line.1234"></a>
+<span class="sourceLineNo">1235</span>    OutputStream out = null;<a name="line.1235"></a>
+<span class="sourceLineNo">1236</span>    try {<a name="line.1236"></a>
+<span class="sourceLineNo">1237</span>      out = new BufferedOutputStream(new FileOutputStream(outfile));<a name="line.1237"></a>
+<span class="sourceLineNo">1238</span>      out.write(encoded.getBytes("US-ASCII")); // Strict, 7-bit output.<a name="line.1238"></a>
+<span class="sourceLineNo">1239</span><a name="line.1239"></a>
+<span class="sourceLineNo">1240</span>    } catch (IOException e) {<a name="line.1240"></a>
+<span class="sourceLineNo">1241</span>      LOG.error("error encoding from file " + infile + " to " + outfile, e);<a name="line.1241"></a>
+<span class="sourceLineNo">1242</span><a name="line.1242"></a>
+<span class="sourceLineNo">1243</span>    } finally {<a name="line.1243"></a>
+<span class="sourceLineNo">1244</span>      if (out != null) {<a name="line.1244"></a>
+<span class="sourceLineNo">1245</span>        try {<a name="line.1245"></a>
+<span class="sourceLineNo">1246</span>          out.close();<a name="line.1246"></a>
+<span class="sourceLineNo">1247</span>        } catch (Exception e) {<a name="line.1247"></a>
+<span class="sourceLineNo">1248</span>          LOG.error("error closing " + outfile, e);<a name="line.1248"></a>
+<span class="sourceLineNo">1249</span>        }<a name="line.1249"></a>
+<span class="sourceLineNo">1250</span>      }<a name="line.1250"></a>
+<span class="sourceLineNo">1251</span>    } // end finally<a name="line.1251"></a>
+<span class="sourceLineNo">1252</span>  } // end encodeFileToFile<a name="line.1252"></a>
+<span class="sourceLineNo">1253</span><a name="line.1253"></a>
+<span class="sourceLineNo">1254</span>  /**<a name="line.1254"></a>
+<span class="sourceLineNo">1255</span>   * Reads &lt;tt&gt;infile&lt;/tt&gt; and decodes it to &lt;tt&gt;outfile&lt;/tt&gt;.<a name="line.1255"></a>
+<span class="sourceLineNo">1256</span>   *<a name="line.1256"></a>
+<span class="sourceLineNo">1257</span>   * @param infile Input file<a name="line.1257"></a>
+<span class="sourceLineNo">1258</span>   * @param outfile Output file<a name="line.1258"></a>
+<span class="sourceLineNo">1259</span>   * @since 2.2<a name="line.1259"></a>
+<span class="sourceLineNo">1260</span>   */<a name="line.1260"></a>
+<span class="sourceLineNo">1261</span>  public static void decodeFileToFile(String infile, String outfile) {<a name="line.1261"></a>
+<span class="sourceLineNo">1262</span>    byte[] decoded = decodeFromFile(infile);<a name="line.1262"></a>
+<span class="sourceLineNo">1263</span>    OutputStream out = null;<a name="line.1263"></a>
+<span class="sourceLineNo">1264</span>    try {<a name="line.1264"></a>
+<span class="sourceLineNo">1265</span>      out = new BufferedOutputStream(new FileOutputStream(outfile));<a name="line.1265"></a>
+<span class="sourceLineNo">1266</span>      out.write(decoded);<a name="line.1266"></a>
+<span class="sourceLineNo">1267</span><a name="line.1267"></a>
+<span class="sourceLineNo">1268</span>    } catch (IOException e) {<a name="line.1268"></a>
+<span class="sourceLineNo">1269</span>      LOG.error("error decoding from file " + infile + " to " + outfile, e);<a name="line.1269"></a>
+<span class="sourceLineNo">1270</span><a name="line.1270"></a>
+<span class="sourceLineNo">1271</span>    } finally {<a name="line.1271"></a>
+<span class="sourceLineNo">1272</span>      if (out != null) {<a name="line.1272"></a>
+<span class="sourceLineNo">1273</span>        try {<a name="line.1273"></a>
+<span class="sourceLineNo">1274</span>          out.close();<a name="line.1274"></a>
+<span class="sourceLineNo">1275</span>        } catch (Exception e) {<a name="line.1275"></a>
+<span class="sourceLineNo">1276</span>          LOG.error("error closing " + outfile, e);<a name="line.1276"></a>
+<span class="sourceLineNo">1277</span>        }<a name="line.1277"></a>
+<span class="sourceLineNo">1278</span>      }<a name="line.1278"></a>
+<span class="sourceLineNo">1279</span>    } // end finally<a name="line.1279"></a>
+<span class="sourceLineNo">1280</span>  } // end decodeFileToFile<a name="line.1280"></a>
+<span class="sourceLineNo">1281</span><a name="line.1281"></a>
+<span class="sourceLineNo">1282</span>  /* ******** I N N E R   C L A S S   I N P U T S T R E A M ******** */<a name="line.1282"></a>
+<span class="sourceLineNo">1283</span><a name="line.1283"></a>
+<span class="sourceLineNo">1284</span>  /**<a name="line.1284"></a>
+<span class="sourceLineNo">1285</span>   * A {@link Base64.Base64InputStream} will read data from another<a name="line.1285"></a>
+<span class="sourceLineNo">1286</span>   * &lt;tt&gt;InputStream&lt;/tt&gt;, given in the constructor, and<a name="line.1286"></a>
+<span class="sourceLineNo">1287</span>   * encode/decode to/from Base64 notation on the fly.<a name="line.1287"></a>
+<span class="sourceLineNo">1288</span>   *<a name="line.1288"></a>
+<span class="sourceLineNo">1289</span>   * @see Base64<a name="line.1289"></a>
+<span class="sourceLineNo">1290</span>   * @since 1.3<a name="line.1290"></a>
+<span class="sourceLineNo">1291</span>   */<a name="line.1291"></a>
+<span class="sourceLineNo">1292</span>  @InterfaceAudience.Public<a name="line.1292"></a>
+<span class="sourceLineNo">1293</span>  @InterfaceStability.Stable<a name="line.1293"></a>
+<span class="sourceLineNo">1294</span>  public static class Base64InputStream extends FilterInputStream {<a name="line.1294"></a>
+<span class="sourceLineNo">1295</span>    private boolean encode;                     // Encoding or decoding<a name="line.1295"></a>
+<span class="sourceLineNo">1296</span>    private int position;                       // Current position in the buffer<a name="line.1296"></a>
+<span class="sourceLineNo">1297</span>    private byte[] buffer;                      // Buffer holding converted data<a name="line.1297"></a>
+<span class="sourceLineNo">1298</span>    private int bufferLength;                   // Length of buffer (3 or 4)<a name="line.1298"></a>
+<span class="sourceLineNo">1299</span>    private int numSigBytes;                    // Meaningful bytes in the buffer<a name="line.1299"></a>
+<span class="sourceLineNo">1300</span>    private int lineLength;<a name="line.1300"></a>
+<span class="sourceLineNo">1301</span>    private boolean breakLines;                 // Break lines at &lt; 80 characters<a name="line.1301"></a>
+<span class="sourceLineNo">1302</span>    private int options;                        // Record options<a name="line.1302"></a>
+<span class="sourceLineNo">1303</span>    private byte[] decodabet;                   // Local copy avoids method calls<a name="line.1303"></a>
+<span class="sourceLineNo">1304</span><a name="line.1304"></a>
+<span class="sourceLineNo">1305</span>    /**<a name="line.1305"></a>
+<span class="sourceLineNo">1306</span>     * Constructs a {@link Base64InputStream} in DECODE mode.<a name="line.1306"></a>
+<span class="sourceLineNo">1307</span>     *<a name="line.1307"></a>
+<span class="sourceLineNo">1308</span>     * @param in the &lt;tt&gt;InputStream&lt;/tt&gt; from which to read data.<a name="line.1308"></a>
+<span class="sourceLineNo">1309</span>     * @since 1.3<a name="line.1309"></a>
+<span class="sourceLineNo">1310</span>     */<a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>    public Base64InputStream(InputStream in) {<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>      this(in, DECODE);<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span>    } // end constructor<a name="line.1313"></a>
+<span class="sourceLineNo">1314</span><a name="line.1314"></a>
+<span class="sourceLineNo">1315</span>    /**<a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>     * Constructs a {@link Base64.Base64InputStream} in either ENCODE or DECODE mode.<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>     * &lt;p&gt;<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>     * Valid options:<a name="line.1318"></a>
 <span class="sourceLineNo">1319</span>     *<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>     * @return next byte<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>     * @since 1.3<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>     */<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>    @Override<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>    public int read() throws IOException {<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      // Do we need to get data?<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>      if (position &lt; 0) {<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>        if (encode) {<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>          byte[] b3 = new byte[3];<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>          int numBinaryBytes = 0;<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>          for (int i = 0; i &lt; 3; i++) {<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>            try {<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>              int b = in.read();<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span><a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>              // If end of stream, b is -1.<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>              if (b &gt;= 0) {<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>                b3[i] = (byte) b;<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>                numBinaryBytes++;<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>              } // end if: not end of stream<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span><a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>            } catch (IOException e) {<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>              // Only a problem if we got no data at all.<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>              if (i == 0)<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>                throw e;<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span><a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>            } // end catch<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>          } // end for: each needed input byte<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span><a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>          if (numBinaryBytes &gt; 0) {<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>            encode3to4(b3, 0, numBinaryBytes, buffer, 0, options);<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>            position = 0;<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>            numSigBytes = 4;<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span><a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>          } else {<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>            return -1;<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>          } // end else<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span><a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>        } else {<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>          byte[] b4 = new byte[4];<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>          int i;<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>          for (i = 0; i &lt; 4; i++) {<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>            // Read four "meaningful" bytes:<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>            int b;<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>            do {<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>              b = in.read();<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>            } while (b &gt;= 0 &amp;&amp; decodabet[b &amp; 0x7f] &lt;= WHITE_SPACE_ENC);<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span><a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>            if (b &lt; 0) {<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>              break; // Reads a -1 if end of stream<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>            }<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span><a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>            b4[i] = (byte) b;<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>          } // end for: each needed input byte<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span><a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>          if (i == 4) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>            numSigBytes = decode4to3(b4, 0, buffer, 0, options);<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>            position = 0;<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span><a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>          } else if (i == 0) {<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>            return -1;<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span><a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>          } else {<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>            // Must have broken out from above.<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>            throw new IOException("Improperly padded Base64 input.");<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>          } // end<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>        } // end else: decode<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>      } // end else: get data<a name="line.1386"></a>
+<span class="sourceLineNo">1320</span>     * &lt;pre&gt;<a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>     *   ENCODE or DECODE: Encode or Decode as data is read.<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>     *   DONT_BREAK_LINES: don't break lines at 76 characters<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span>     *     (only meaningful when encoding)<a name="line.1323"></a>
+<span class="sourceLineNo">1324</span>     *     &amp;lt;i&amp;gt;Note: Technically, this makes your encoding non-compliant.&amp;lt;/i&amp;gt;<a name="line.1324"></a>
+<span class="sourceLineNo">1325</span>     * &lt;/pre&gt;<a name="line.1325"></a>
+<span class="sourceLineNo">1326</span>     *<a name="line.1326"></a>
+<span class="sourceLineNo">1327</span>     * &lt;p&gt;<a name="line.1327"></a>
+<span class="sourceLineNo">1328</span>     * Example: &lt;code&gt;new Base64.Base64InputStream( in, Base64.DECODE )&lt;/code&gt;<a name="line.1328"></a>
+<span class="sourceLineNo">1329</span>     *<a name="line.1329"></a>
+<span class="sourceLineNo">1330</span>     *<a name="line.1330"></a>
+<span class="sourceLineNo">1331</span>     * @param in the &lt;tt&gt;InputStream&lt;/tt&gt; from which to read data.<a name="line.1331"></a>
+<span class="sourceLineNo">1332</span>     * @param options Specified options<a name="line.1332"></a>
+<span class="sourceLineNo">1333</span>     * @see Base64#ENCODE<a name="line.1333"></a>
+<span class="sourceLineNo">1334</span>     * @see Base64#DECODE<a name="line.1334"></a>
+<span class="sourceLineNo">1335</span>     * @see Base64#DONT_BREAK_LINES<a name="line.1335"></a>
+<span class="sourceLineNo">1336</span>     * @since 2.0<a name="line.1336"></a>
+<span class="sourceLineNo">1337</span>     */<a name="line.1337"></a>
+<span class="sourceLineNo">1338</span>    public Base64InputStream(InputStream in, int options) {<a name="line.1338"></a>
+<span class="sourceLineNo">1339</span>      super(in);<a name="line.1339"></a>
+<span class="sourceLineNo">1340</span>      this.breakLines = (options &amp; DONT_BREAK_LINES) != DONT_BREAK_LINES;<a name="line.1340"></a>
+<span class="sourceLineNo">1341</span>      this.encode = (options &amp; ENCODE) == ENCODE;<a name="line.1341"></a>
+<span class="sourceLineNo">1342</span>      this.bufferLength = encode ? 4 : 3;<a name="line.1342"></a>
+<span class="sourceLineNo">1343</span>      this.buffer = new byte[bufferLength];<a name="line.1343"></a>
+<span class="sourceLineNo">1344</span>      this.position = -1;<a name="line.1344"></a>
+<span class="sourceLineNo">1345</span>      this.lineLength = 0;<a name="line.1345"></a>
+<span class="sourceLineNo">1346</span>      this.options = options; // Record for later, mostly to determine which<a name="line.1346"></a>
+<span class="sourceLineNo">1347</span>                              // alphabet to use<a name="line.1347"></a>
+<span class="sourceLineNo">1348</span>      this.decodabet = getDecodabet(options);<a name="line.1348"></a>
+<span class="sourceLineNo">1349</span>    } // end constructor<a name="line.1349"></a>
+<span class="sourceLineNo">1350</span><a name="line.1350"></a>
+<span class="sourceLineNo">1351</span>    /**<a name="line.1351"></a>
+<span class="sourceLineNo">1352</span>     * Reads enough of the input stream to convert to/from Base64 and returns<a name="line.1352"></a>
+<span class="sourceLineNo">1353</span>     * the next byte.<a name="line.1353"></a>
+<span class="sourceLineNo">1354</span>     *<a name="line.1354"></a>
+<span class="sourceLineNo">1355</span>     * @return next byte<a name="line.1355"></a>
+<span class="sourceLineNo">1356</span>     * @since 1.3<a name="line.1356"></a>
+<span class="sourceLineNo">1357</span>     */<a name="line.1357"></a>
+<span class="sourceLineNo">1358</span>    @Override<a name="line.1358"></a>
+<span class="sourceLineNo">1359</span>    public int read() throws IOException {<a name="line.1359"></a>
+<span class="sourceLineNo">1360</span>      // Do we need to get data?<a name="line.1360"></a>
+<span class="sourceLineNo">1361</span>      if (position &lt; 0) {<a name="line.1361"></a>
+<span class="sourceLineNo">1362</span>        if (encode) {<a name="line.1362"></a>
+<span class="sourceLineNo">1363</span>          byte[] b3 = new byte[3];<a name="line.1363"></a>
+<span class="sourceLineNo">1364</span>          int numBinaryBytes = 0;<a name="line.1364"></a>
+<span class="sourceLineNo">1365</span>          for (int i = 0; i &lt; 3; i++) {<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>            try {<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>              int b = in.read();<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span><a name="line.1368"></a>
+<span class="sourceLineNo">1369</span>              // If end of stream, b is -1.<a name="line.1369"></a>
+<span class="sourceLineNo">1370</span>              if (b &gt;= 0) {<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>                b3[i] = (byte) b;<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span>                numBinaryBytes++;<a name="line.1372"></a>
+<span class="sourceLineNo">1373</span>              } // end if: not end of stream<a name="line.1373"></a>
+<span class="sourceLineNo">1374</span><a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>            } catch (IOException e) {<a name="line.1375"></a>
+<span class="sourceLineNo">1376</span>              // Only a problem if we got no data at all.<a name="line.1376"></a>
+<span class="sourceLineNo">1377</span>              if (i == 0)<a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>                throw e;<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span><a name="line.1379"></a>
+<span class="sourceLineNo">1380</span>            } // end catch<a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>          } // end for: each needed input byte<a name="line.1381"></a>
+<span class="sourceLineNo">1382</span><a name="line.1382"></a>
+<span class="sourceLineNo">1383</span>          if (numBinaryBytes &gt; 0) {<a name="line.1383"></a>
+<span class="sourceLineNo">1384</span>            encode3to4(b3, 0, numBinaryBytes, buffer, 0, options);<a name="line.1384"></a>
+<span class="sourceLineNo">1385</span>            position = 0;<a name="line.1385"></a>
+<span class="sourceLineNo">1386</span>            numSigBytes = 4;<a name="line.1386"></a>
 <span class="sourceLineNo">1387</span><a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>      // Got data?<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>      if (position &gt;= 0) {<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>        // End of relevant data?<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>        if ( /* !encode &amp;&amp; */position &gt;= numSigBytes) {<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>          return -1;<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>        }<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span><a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>        if (encode &amp;&amp; breakLines &amp;&amp; lineLength &gt;= MAX_LINE_LENGTH) {<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>          lineLength = 0;<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>          return '\n';<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span><a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>        }<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>        lineLength++;                   // This isn't important when decoding<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>                                        // but throwing an extra "if" seems<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>                                        // just as wasteful.<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span><a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>        int b = buffer[position++];<a name="line.1404"></a>
+<span class="sourceLineNo">1388</span>          } else {<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span>            return -1;<a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>          } // end else<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span><a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>        } else {<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>          byte[] b4 = new byte[4];<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span>          int i;<a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>          for (i = 0; i &lt; 4; i++) {<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>            // Read four "meaningful" bytes:<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span>            int b;<a name="line.1397"></a>
+<span class="sourceLineNo">1398</span>            do {<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>              b = in.read();<a name="line.1399"></a>
+<span class="sourceLineNo">1400</span>            } while (b &gt;= 0 &amp;&amp; decodabet[b &amp; 0x7f] &lt;= WHITE_SPACE_ENC);<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span><a name="line.1401"></a>
+<span class="sourceLineNo">1402</span>            if (b &lt; 0) {<a name="line.1402"></a>
+<span class="sourceLineNo">1403</span>              break; // Reads a -1 if end of stream<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>            }<a name="line.1404"></a>
 <span class="sourceLineNo">1405</span><a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>        if (position &gt;= bufferLength)<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>          position = -1;<a name="line.1407"></a>
+<span class="sourceLineNo">1406</span>            b4[i] = (byte) b;<a name="line.1406"></a>
+<span class="sourceLineNo">1407</span>          } // end for: each needed input byte<a name="line.1407"></a>
 <span class="sourceLineNo">1408</span><a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>        return b &amp; 0xFF;                // This is how you "cast" a byte that's<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>                                        // intended to be unsigned.<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span><a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>      }<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span><a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>      // When JDK1.4 is more accepted, use an assertion here.<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>      throw new IOException("Error in Base64 code reading stream.");<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span><a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>    } // end read<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span><a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>    /**<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>     * Calls {@link #read()} repeatedly until the end of stream is reached or<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>     * &lt;var&gt;len&lt;/var&gt; bytes are read. Returns number of bytes read into array<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>     * or -1 if end of stream is encountered.<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>     *<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>     * @param dest array to hold values<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>     * @param off offset for array<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>     * @param len max number of bytes to read into array<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>     * @return bytes read into array or -1 if end of stream is encountered.<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>     * @since 1.3<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>     */<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>    @Override<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>    public int read(byte[] dest, int off, int len) throws IOException {<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>      int i;<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>      int b;<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>      for (i = 0; i &lt; len; i++) {<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>        b = read();<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>        if (b &gt;= 0) {<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>          dest[off + i] = (byte) b;<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>        } else if (i == 0) {<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>          return -1;<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>        } else {<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>          break; // Out of 'for' loop<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>        }<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>      } // end for: each byte read<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>      return i;<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>    } // end read<a name="line.1445"></a>
+<span class="sourceLineNo">1409</span>          if (i == 4) {<a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>            numSigBytes = decode4to3(b4, 0, buffer, 0, options);<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span>            position = 0;<a name="line.1411"></a>
+<span class="sourceLineNo">1412</span><a name="line.1412"></a>
+<span class="sourceLineNo">1413</span>          } else if (i == 0) {<a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>            return -1;<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span><a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>          } else {<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>            // Must have broken out from above.<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>            throw new IOException("Improperly padded Base64 input.");<a name="line.1418"></a>
+<span class="sourceLineNo">1419</span>          } // end<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>        } // end else: decode<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span>      } // end else: get data<a name="line.1421"></a>
+<span class="sourceLineNo">1422</span><a name="line.1422"></a>
+<span class="sourceLineNo">1423</span>      // Got data?<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span>      if (position &gt;= 0) {<a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>        // End of relevant data?<a name="line.1425"></a>
+<span class="sourceLineNo">1426</span>        if ( /* !encode &amp;&amp; */position &gt;= numSigBytes) {<a name="line.1426"></a>
+<span class="sourceLineNo">1427</span>          return -1;<a name="line.1427"></a>
+<span class="sourceLineNo">1428</span>        }<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span><a name="line.1429"></a>
+<span class="sourceLineNo">1430</span>        if (encode &amp;&amp; breakLines &amp;&amp; lineLength &gt;= MAX_LINE_LENGTH) {<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span>          lineLength = 0;<a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>          return '\n';<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span><a name="line.1433"></a>
+<span class="sourceLineNo">1434</span>        }<a name="line.1434"></a>
+<span class="sourceLineNo">1435</span>        lineLength++;                   // This isn't important when decoding<a name="line.1435"></a>
+<span class="sourceLineNo">1436</span>                                        // but throwing an extra "if" seems<a name="line.1436"></a>
+<span class="sourceLineNo">1437</span>                                        // just as wasteful.<a name="line.1437"></a>
+<span class="sourceLineNo">1438</span><a name="line.1438"></a>
+<span class="sourceLineNo">1439</span>        int b = buffer[position++];<a name="line.1439"></a>
+<span class="sourceLineNo">1440</span><a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>        if (position &gt;= bufferLength)<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span>          position = -1;<a name="line.1442"></a>
+<span class="sourceLineNo">1443</span><a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>        return b &amp; 0xFF;                // This is how you "cast" a byte that's<a name="line.1444"></a>
+<span class="sourceLineNo">1445</span>                                        // intended to be unsigned.<a name="line.1445"></a>
 <span class="sourceLineNo">1446</span><a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>  } // end inner class InputStream<a name="line.1447"></a>
+<span class="sourceLineNo">1447</span>      }<a name="line.1447"></a>
 <span class="sourceLineNo">1448</span><a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>  /* ******** I N N E R   C L A S S   O U T P U T S T R E A M ******** */<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span><a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>  /**<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>   * A {@link Base64.Base64OutputStream} will write data to another<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>   * &lt;tt&gt;OutputStream&lt;/tt&gt;, given in the constructor, and<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>   * encode/decode to/from Base64 notation on the fly.<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>   *<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>   * @see Base64<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>   * @since 1.3<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>   */<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>  @InterfaceAudience.Public<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>  @InterfaceStability.Stable<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>  public static class Base64OutputStream extends FilterOutputStream {<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span>    private boolean encode;<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>    private int position;<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>    private byte[] buffer;<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>    private int bufferLength;<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>    private int lineLength;<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>    private boolean breakLines;<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>    private byte[] b4;                          // Scratch used in a few places<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>    private boolean suspendEncoding;<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>    private int options;                        // Record for later<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>    private byte[] decodabet;                   // Local copy avoids method calls<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span><a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>    /**<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>     * Constructs a {@link Base64OutputStream} in ENCODE mode.<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>     *<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>     * @param out the &lt;tt&gt;OutputStream&lt;/tt&gt; to which data will be written.<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>     * @since 1.3<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>     */<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>    public Base64OutputStream(OutputStream out) {<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>      this(out, ENCODE);<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>    } // end constructor<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span><a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>    /**<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>     * Constructs a {@link Base64OutputStream} in either ENCODE or DECODE mode.<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>     * &lt;p&gt;<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>     * Valid options:<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>     *<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>     * &lt;ul&gt;<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>     *   &lt;li&gt;ENCODE or DECODE: Encode or Decode as data is read.&lt;/li&gt;<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>     *   &lt;li&gt;DONT_BREAK_LINES: don't break lines at 76 characters (only<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>     *     meaningful when encoding) &lt;i&gt;Note: Technically, this makes your<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>     *     encoding non-compliant.&lt;/i&gt;&lt;/li&gt;<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>     * &lt;/ul&gt;<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>     *<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>     * &lt;p&gt;<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>     * Example: &lt;code&gt;new Base64.Base64OutputStream( out, Base64.ENCODE )&lt;/code&gt;<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>     *<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>     * @param out the &lt;tt&gt;OutputStream&lt;/tt&gt; to which data will be written.<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>     * @param options Specified options.<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>     * @see Base64#ENCODE<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>     * @see Base64#DECODE<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>     * @see Base64#DONT_BREAK_LINES<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>     * @since 1.3<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>     */<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>    @InterfaceAudience.Public<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>    @InterfaceStability.Stable<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>    public Base64OutputStream(OutputStream out, int options) {<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>      super(out);<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>      this.breakLines = (options &amp; DONT_BREAK_LINES) != DONT_BREAK_LINES;<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>      this.encode = (options &amp; ENCODE) == ENCODE;<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>      this.bufferLength = encode ? 3 : 4;<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>      this.buffer = new byte[bufferLength];<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>      this.position = 0;<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>      this.lineLength = 0;<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>      this.suspendEncoding = false;<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>      this.b4 = new byte[4];<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>      this.options = options;<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>      this.decodabet = getDecodabet(options);<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>    } // end constructor<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span><a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>    /**<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>     * Writes the byte to the output stream after converting to/from Base64<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>     * notation. When encoding, bytes are buffered three at a time before the<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>     * output stream actually gets a write() call. When decoding, bytes are<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>     * buffered four at a time.<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>     *<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>     * @param theByte the byte to write<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>     * @since 1.3<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>     */<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>    @Override<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>    public void write(int theByte) throws IOException {<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>      // Encoding suspended?<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>      if (suspendEncoding) {<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>        super.out.write(theByte);<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>        return;<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>      } // end if: supsended<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span><a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>      // Encode?<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>      if (encode) {<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>        buffer[position++] = (byte) theByte;<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>        if (position &gt;= bufferLength) {                 // Enough to encode.<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>          out.write(encode3to4(b4, buffer, bufferLength, options));<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>          lineLength += 4;<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>          if (breakLines &amp;&amp; lineLength &gt;= MAX_LINE_LENGTH) {<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>            out.write(NEW_LINE);<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>            lineLength = 0;<a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>          } // end if: end of line<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span><a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>          position = 0;<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>        } // end if: enough to output<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span><a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>      } else {<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>        // Meaningful Base64 character?<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>        if (decodabet[theByte &amp; 0x7f] &gt; WHITE_SPACE_ENC) {<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>          buffer[position++] = (byte) theByte;<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>          if (position &gt;= bufferLength) {               // Enough to output.<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>            int len = decode4to3(buffer, 0, b4, 0, options);<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>            out.write(b4, 0, len);<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>            position = 0;<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>          } // end if: enough to output<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span><a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>        } else if (decodabet[theByte &amp; 0x7f] != WHITE_SPACE_ENC) {<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>          throw new IOException("Invalid character in Base64 data.");<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>        } // end else: not white space either<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>      } // end else: decoding<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>    } // end write<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span><a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>    /**<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>     * Calls {@link #write(int)} repeatedly until &lt;var&gt;len&lt;/var&gt; bytes are<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>     * written.<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>     *<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>     * @param theBytes array from which to read bytes<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>     * @param off offset for array<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>     * @param len max number of bytes to read into array<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>     * @since 1.3<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>     */<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>    @Override<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>    public void write(byte[] theBytes, int off, int len) throws IOException {<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>      // Encoding suspended?<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>      if (suspendEncoding) {<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        super.out.write(theBytes, off, len);<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>        return;<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>      } // end if: supsended<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span><a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>      for (int i = 0; i &lt; len; i++) {<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>        write(theBytes[off + i]);<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>      } // end for: each byte written<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span><a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>    } // end write<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span><a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>    /**<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>     * Method added by PHIL. [Thanks, PHIL. -Rob] This pads the buffer without<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>     * closing the stream.<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>     *<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>     * @throws IOException e<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>     */<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>    public void flushBase64() throws IOException {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>      if (position &gt; 0) {<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>        if (encode) {<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>          out.write(encode3to4(b4, buffer, position, options));<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>          position = 0;<a name="line.1601"></a>
+<span class="sourceLineNo">1449</span>      // When JDK1.4 is more accepted, use an assertion here.<a name="line.1449"></a>
+<span class="sourceLineNo">1450</span>      throw new IOException("Error in Base64 code reading stream.");<a name="line.1450"></a>
+<span class="sourceLineNo">1451</span><a name="line.1451"></a>
+<span class="sourceLineNo">1452</span>    } // end read<a name="line.1452"></a>
+<span class="sourceLineNo">1453</span><a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>    /**<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span>     * Calls {@link #read()} repeatedly until the end of stream is reached or<a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>     * &lt;var&gt;len&lt;/var&gt; bytes are read. Returns number of bytes read into array<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>     * or -1 if end of stream is encountered.<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>     *<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span>     * @param dest array to hold values<a name="line.1459"></a>
+<span class="sourceLineNo">1460</span>     * @param off offset for array<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span>     * @param len max number of bytes to read into array<a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>     * @return bytes read into array or -1 if end of stream is encountered.<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span>     * @since 1.3<a name="line.1463"></a>
+<span class="sourceLineNo">1464</span>     */<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span>    @Override<a name="line.1465"></a>
+<span class="sourceLineNo">1466</span>    public int read(byte[] dest, int off, int len) throws IOException {<a name="line.1466"></a>
+<span class="sourceLineNo">1467</span>      int i;<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span>      int b;<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>      for (i = 0; i &lt; len; i++) {<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>        b = read();<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>        if (b &gt;= 0) {<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span>          dest[off + i] = (byte) b;<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>        } else if (i == 0) {<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>          return -1;<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span>        } else {<a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>          break; // Out of 'for' loop<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>        }<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span>      } // end for: each byte read<a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>      return i;<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>    } // end read<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span><a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>  } // end inner class InputStream<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span><a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>  /* ******** I N N E R   C L A S S   O U T P U T S T R E A M ******** */<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span><a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>  /**<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span>   * A {@link Base64.Base64OutputStream} will write data to another<a name="line.1487"></a>
+<span class="sourceLineNo">1488</span>   * &lt;tt&gt;OutputStream&lt;/tt&gt;, given in the constructor, and<a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>   * encode/decode to/from Base64 notation on the fly.<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>   *<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>   * @see Base64<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>   * @since 1.3<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>   */<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>  @InterfaceAudience.Public<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>  @InterfaceStability.Stable<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>  public static class Base64OutputStream extends FilterOutputStream {<a name="line.1496"></a>
+<span class="sourceLineNo">1497</span>    private boolean encode;<a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>    private int position;<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>    private byte[] buffer;<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>    private int bufferLength;<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>    private int lineLength;<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>    private boolean breakLines;<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>    private byte[] b4;                          // Scratch used in a few places<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>    private boolean suspendEncoding;<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>    private int options;                        // Record for later<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span>    private byte[] decodabet;                   // Local copy avoids method calls<a name="line.1506"></a>
+<span class="sourceLineNo">1507</span><a name="line.1507"></a>
+<span class="sourceLineNo">1508</span>    /**<a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>     * Constructs a {@link Base64OutputStream} in ENCODE mode.<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>     *<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>     * @param out the &lt;tt&gt;OutputStream&lt;/tt&gt; to which data will be written.<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>     * @since 1.3<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>     */<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>    public Base64OutputStream(OutputStream out) {<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>      this(out, ENCODE);<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>    } // end constructor<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span><a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>    /**<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>     * Constructs a {@link Base64OutputStream} in either ENCODE or DECODE mode.<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>     * &lt;p&gt;<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>     * Valid options:<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>     *<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>     * &lt;ul&gt;<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>     *   &lt;li&gt;ENCODE or DECODE: Encode or Decode as data is read.&lt;/li&gt;<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>     *   &lt;li&gt;DONT_BREAK_LINES: don't break lines at 76 characters (only<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>     *     meaningful when encoding) &lt;i&gt;Note: Technically, this makes your<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>     *     encoding non-compliant.&lt;/i&gt;&lt;/li&gt;<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>     * &lt;/ul&gt;<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>     *<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>     * &lt;p&gt;<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>     * Example: &lt;code&gt;new Base64.Base64OutputStream( out, Base64.ENCODE )&lt;/code&gt;<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>     *<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>     * @param out the &lt;tt&gt;OutputStream&lt;/tt&gt; to which data will be written.<a name="line.1533"></a>
+<span class="sourceL

<TRUNCATED>

Mime
View raw message