package org.openstack.utils;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;

/**
 * Helper class that does String <-> UTF8 encoding
 * 
 */
public class Utf8 {
	static final Charset CHARSET = Charset.forName("UTF-8");

	private Utf8() {
	}

	public static String toString(ByteArrayOutputStream baos) {
		return toString(baos.toByteArray());
	}

	public static String toString(byte[] bytes) {
		return new String(bytes, CHARSET);
	}

	public static byte[] getBytes(String s) {
		return s.getBytes(CHARSET);
	}

	public static InputStreamReader openFile(File file) throws FileNotFoundException {
		return new InputStreamReader(new FileInputStream(file), CHARSET);
	}

	public static Reader openReader(InputStream is) {
		return new InputStreamReader(is, CHARSET);
	}

}

@@ -206,32 +206,96 @@
 utStreamReader;%0A
+import java.io.OutputStream;%0Aimport java.io.OutputStreamWriter;%0A
 import java.io.R
@@ -1024,10 +1024,143 @@
 T);%0A%09%7D%0A%0A
+%09public static OutputStreamWriter openWriter(OutputStream outputStream) %7B%0A%09%09return new OutputStreamWriter(outputStream, CHARSET);%0A%09%7D%0A
 %7D%0A

Add Utf8 openWriter helper