Java examples for XML:XML Encoding
Write bytes into the OutputStream by given encoding.
/************************************************************************** * Licensed Material - Property of Dawn InfoTek * * Copyright (c) Dawn InfoTek Inc. 1999, 2004, 2008 -All rights reserved. * * (<http://www.dawninfotek.com>) * * * * This file contains proprietary intellectual property of * * Dawn InfoTek Inc. The contents of and information in this file * * is only to be used in conjunction with a valid Dawn4J license * * as specified in the Dawn4J license agreement. All other use * * is prohibited. * **************************************************************************/ import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; import java.util.Scanner; import org.apache.log4j.Logger; public class Main{ /**/* www . j av a2 s. c o m*/ * Logger for this class */ private static final Logger logger = Logger.getLogger(XMLUtil.class); /** * Write bytes into the OutputStream by given encoding. * * @param os the os * @param bytes the bytes * @param encoding the encoding * * @throws IOException Signals that an I/O exception has occurred. */ public static void writeByte(OutputStream os, byte[] bytes, String encoding) throws IOException { String length = String.valueOf(bytes.length); if (XMLUtil.logger.isDebugEnabled()) { XMLUtil.logger.debug(XMLUtil.class.getName() + " sending message length is:" + length + ",encoding is " + encoding); } os.write(bytes); os.flush(); } }