X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FStringUtils.java;h=baa8e26c17fcfac7ba09c21188d6c6f30b765e23;hb=f28a134e4d06ee40d62c0c62123fc4799d49d8eb;hp=36fdfbe2c967359d0677c3935bd1c56b75346b44;hpb=8758aebb45238a0193b8d09b987b80ac3cdf0513;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/StringUtils.java b/src/be/nikiroo/utils/StringUtils.java index 36fdfbe..baa8e26 100644 --- a/src/be/nikiroo/utils/StringUtils.java +++ b/src/be/nikiroo/utils/StringUtils.java @@ -21,6 +21,9 @@ import org.unbescape.html.HtmlEscape; import org.unbescape.html.HtmlEscapeLevel; import org.unbescape.html.HtmlEscapeType; +import be.nikiroo.utils.streams.Base64InputStream; +import be.nikiroo.utils.streams.Base64OutputStream; + /** * This class offer some utilities based around {@link String}s. * @@ -604,12 +607,11 @@ public class StringUtils { * @throws IOException * in case of I/O errors */ + @Deprecated public static OutputStream base64(OutputStream data, boolean zip, boolean breakLines) throws IOException { - OutputStream out = new Base64.OutputStream(data, - breakLines ? Base64.DO_BREAK_LINES & Base64.ENCODE - : Base64.ENCODE); - + OutputStream out = new Base64OutputStream(data, true); + if (zip) { out = new java.util.zip.GZIPOutputStream(out); } @@ -634,14 +636,14 @@ public class StringUtils { * @throws IOException * in case of I/O errors */ + @Deprecated public static InputStream base64(InputStream data, boolean zip, boolean breakLines) throws IOException { if (zip) { data = new java.util.zip.GZIPInputStream(data); } - return new Base64.InputStream(data, breakLines ? Base64.DO_BREAK_LINES - & Base64.ENCODE : Base64.ENCODE); + return new Base64InputStream(data, true); } /** @@ -682,9 +684,11 @@ public class StringUtils { * @throws IOException * in case of I/O errors */ + @Deprecated public static OutputStream unbase64(OutputStream data, boolean zip) throws IOException { - OutputStream out = new Base64.OutputStream(data, Base64.DECODE); + OutputStream out = new Base64OutputStream(data, false); + if (zip) { out = new java.util.zip.GZIPOutputStream(out); @@ -708,13 +712,14 @@ public class StringUtils { * @throws IOException * in case of I/O errors */ + @Deprecated public static InputStream unbase64(InputStream data, boolean zip) throws IOException { if (zip) { data = new java.util.zip.GZIPInputStream(data); } - return new Base64.InputStream(data, Base64.DECODE); + return new Base64InputStream(data, false); } /** @@ -799,11 +804,13 @@ public class StringUtils { * Return a display {@link String} for the given value, which can be * suffixed with "k" or "M" depending upon the number, if it is big enough. *
- * Example: + *
+ * Examples: *
- * Example: + * Examples (assuming decimalPositions = 1): *