// Path: src/main/java/org/ardverk/io/ByteUtils.java
// public class ByteUtils {
// 
//   private ByteUtils() {}
//   
//   /**
//    * @see DataInput#readFully(byte[])
//    */
//   public static byte[] readFully(InputStream in, byte[] dst) throws IOException {
//     return readFully(in, dst, 0, dst.length);
//   }
//   
//   /**
//    * @see DataInput#readFully(byte[])
//    */
//   public static byte[] readFully(InputStream in, byte[] dst, 
//       int offset, int length) throws IOException {
//     
//     int total = 0;
//     while (total < length) {
//       int r = in.read(dst, offset + total, length - total);
//       if (r == -1) {
//         throw new EOFException();
//       }
//       
//       total += r;
//     }
//     
//     return dst;
//   }
//   
//   public static void writeBytes(byte[] data, OutputStream out) throws IOException {
//     writeBytes(data, 0, data.length, out);
//   }
//   
//   public static void writeBytes(byte[] data, int offset, int length, 
//       OutputStream out) throws IOException {
//     DataUtils.int2vbeb(length, out);
//     out.write(data, offset, length);
//   }
//   
//   public static byte[] readBytes(InputStream in) throws IOException {
//     int length = DataUtils.vbeb2int(in);
//     byte[] data = new byte[length];
//     return readFully(in, data);
//   }
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import org.ardverk.io.ByteUtils;
    return getBytes(data, UTF8_CHARSET);
  }
  
  public static byte[] getBytes(String data, String encoding) {
    return getBytes(data, Charset.forName(encoding));
  }
  
  public static byte[] getBytes(String data, Charset encoding) {
    return data.getBytes(encoding);
  }
  
  /**
   * Writes the {@link String} to the given {@link OutputStream}.
   */
  public static void writeString(String value, OutputStream out) throws IOException {
    writeString(value, UTF8_CHARSET, out);
  }
  
  /**
   * Writes the {@link String} to the given {@link OutputStream}.
   */
  public static void writeString(String value, String encoding, OutputStream out) throws IOException {
    writeString(value, Charset.forName(encoding), out);
  }
  
  /**
   * Writes the {@link String} to the given {@link OutputStream}.
   */
  public static void writeString(String value, Charset encoding, OutputStream out) throws IOException {
    byte[] data = getBytes(value, encoding);
// Path: src/main/java/org/ardverk/io/ByteUtils.java
// public class ByteUtils {
// 
//   private ByteUtils() {}
//   
//   /**
//    * @see DataInput#readFully(byte[])
//    */
//   public static byte[] readFully(InputStream in, byte[] dst) throws IOException {
//     return readFully(in, dst, 0, dst.length);
//   }
//   
//   /**
//    * @see DataInput#readFully(byte[])
//    */
//   public static byte[] readFully(InputStream in, byte[] dst, 
//       int offset, int length) throws IOException {
//     
//     int total = 0;
//     while (total < length) {
//       int r = in.read(dst, offset + total, length - total);
//       if (r == -1) {
//         throw new EOFException();
//       }
//       
//       total += r;
//     }
//     
//     return dst;
//   }
//   
//   public static void writeBytes(byte[] data, OutputStream out) throws IOException {
//     writeBytes(data, 0, data.length, out);
//   }
//   
//   public static void writeBytes(byte[] data, int offset, int length, 
//       OutputStream out) throws IOException {
//     DataUtils.int2vbeb(length, out);
//     out.write(data, offset, length);
//   }
//   
//   public static byte[] readBytes(InputStream in) throws IOException {
//     int length = DataUtils.vbeb2int(in);
//     byte[] data = new byte[length];
//     return readFully(in, data);
//   }
// }


// Path: src/main/java/org/ardverk/utils/StringUtils.java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import org.ardverk.io.ByteUtils;

    return getBytes(data, UTF8_CHARSET);
  }
  
  public static byte[] getBytes(String data, String encoding) {
    return getBytes(data, Charset.forName(encoding));
  }
  
  public static byte[] getBytes(String data, Charset encoding) {
    return data.getBytes(encoding);
  }
  
  /**
   * Writes the {@link String} to the given {@link OutputStream}.
   */
  public static void writeString(String value, OutputStream out) throws IOException {
    writeString(value, UTF8_CHARSET, out);
  }
  
  /**
   * Writes the {@link String} to the given {@link OutputStream}.
   */
  public static void writeString(String value, String encoding, OutputStream out) throws IOException {
    writeString(value, Charset.forName(encoding), out);
  }
  
  /**
   * Writes the {@link String} to the given {@link OutputStream}.
   */
  public static void writeString(String value, Charset encoding, OutputStream out) throws IOException {
    byte[] data = getBytes(value, encoding);
    ByteUtils.writeBytes(data, out);