Author: sebb
Date: Thu May 13 09:59:42 2010
New Revision: 943858

URL: http://svn.apache.org/viewvc?rev=943858&view=rev
Log:
New utility method toAsciiString(final byte[] inputBytes, int offset, int 
length)

Modified:
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java?rev=943858&r1=943857&r2=943858&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java
 Thu May 13 09:59:42 2010
@@ -115,6 +115,22 @@ public class ArchiveUtils {
     }
 
     /**
+     * Convert an input byte array to a String using the ASCII character set.
+     * 
+     * @param inputBytes input byte array
+     * @param offset offset within array
+     * @param length length of array
+     * @return the bytes, interpreted as an Ascii string
+     */
+    public static String toAsciiString(final byte[] inputBytes, int offset, 
int length){
+        try {
+            return new String(inputBytes, offset, length, "ASCII");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e); // Should never happen
+        }
+    }
+
+    /**
      * Compare byte buffers, optionally ignoring trailing nulls
      * 
      * @param buffer1


Reply via email to