import java.io.ByteArrayOutputStream; 
import java.io.IOException; 
import java.nio.ByteBuffer; 
import java.nio.charset.CodingErrorAction; 
import java.nio.charset.StandardCharsets; 
import java.util.jar.Attributes; 
import java.util.jar.Manifest; 

public class JI9053627 {

	public static void main(String[] args) throws IOException {
		// Create empty manifest 
		Manifest m = new Manifest(); 
		m.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); 
		// Add multibyte characters (here it's a 2-byte German umlaut) 
		m.getMainAttributes().put(new Attributes.Name("Attribute"), "Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤Ã¤"); 
		final ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
		// Write the manifest to a byte array 
		m.write(baos); 
		// Print the serialized manifest 
		System.out.println(new String(baos.toByteArray(), StandardCharsets.UTF_8)); 
		// Try to decode the written bytes to a UTF-8 string (this fails!) 
		StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).decode(ByteBuffer.wrap(baos.toByteArray())); 

	}

}
