X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fstreams%2FStreamUtils.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Fstreams%2FStreamUtils.java;h=9b9ffe653c8d7823dbfdc9f279b950711a51e066;hb=627f866e6cd474bd7494750dc3846c5ad898f2ec;hp=6b8251a6e692f498452d8dcacab6d0d1958318f7;hpb=1dd9b99ff5da048acdc65e62cf8131a58f649be0;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/streams/StreamUtils.java b/src/be/nikiroo/utils/streams/StreamUtils.java index 6b8251a..9b9ffe6 100644 --- a/src/be/nikiroo/utils/streams/StreamUtils.java +++ b/src/be/nikiroo/utils/streams/StreamUtils.java @@ -55,7 +55,7 @@ class StreamUtils { * UTF-8. * * @param str - * the string to transform into bytes + * the {@link String} to transform into bytes * @return the content in bytes */ static public byte[] bytes(String str) { @@ -67,4 +67,26 @@ class StreamUtils { return null; } } + + /** + * Return the bytes array representation of the given {@link String} in + * UTF-8. + * + * @param strs + * the {@link String}s to transform into bytes + * @return the content in bytes + */ + static public byte[][] bytes(String[] strs) { + try { + byte[][] bytes = new byte[strs.length][]; + for (int i = 0; i < strs.length; i++) { + bytes[i] = strs[i].getBytes("UTF-8"); + } + return bytes; + } catch (UnsupportedEncodingException e) { + // All conforming JVM must support UTF-8 + e.printStackTrace(); + return null; + } + } }