Found this cool site containing a consolidated listing of "connection-strings" that can be applied to most of the databases out there. Quite valuable for quick reference :)
http://www.connectionstrings.com/
http://www.connectionstrings.com/
Digital Transformation, Artificial Intelligence, Machine Learning, IoT, Big Data Analytics, Enterprise Architecture, Performance Engineering, Security, Design and Development tips on Java and .NET platforms.
import java.io.File; import com.google.common.io.Files; public class Chinese_Chars { public static void main (String arg[])throws Exception{ String str = "\u6587\u4EF6"; byte[] array = str.getBytes("UTF-8"); File file = new File("d:/temp.txt"); Files.write(array, file); } }---------------------------------------------------
BindingProvider bp = (BindingProvider) smDispatch; bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); bp.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE); bp.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://tempuri.org/IVtOwl/AcceptVehicleTermsOfService");// Correct SOAP Action
//read a file from the classpath, as we want to avoid absolute paths.. File file = new File(getClass().getResource("/com/company/project/test.txt").getFile()); //pass a proper charset to ensure proper encoding List<String>lines = Files.readLines(file, Charsets.UTF_8);
Another alternate method to read the entire content of the file as a string -
public static String toString(File file,Charset charset)
public static byte[] toByteArray(File file)
public class TimePass { public static void main(String[] args) { if ( false == true ) { //these characters are ignored?: \u000a\u007d\u007b System.out.println("false is true!"); } } }
import java.util.logging.Logger; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; import org.jboss.netty.util.CharsetUtil; public class NarenLengthFieldDecoder extends FrameDecoder { private static final Logger logger = Logger.getLogger(NarenLengthFieldDecoder.class.getName()); public int lengthFieldLength = 2; // some default value public NarenLengthFieldDecoder(int length) { this.lengthFieldLength = length; } @Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { // wait until the length prefix is available. if (buffer.readableBytes() < lengthFieldLength) { // return null to inform frame decoder that frame is not yet // complete and to continue reading data return null; } // read length field...create a byteArray for the length field and copy // the first bytes into it.. byte[] array = new byte[lengthFieldLength]; buffer.readBytes(array); // Imp: readBytes also forwards the readerIndex // Mark the current buffer position before reading the length field // because the whole frame might not be in the buffer yet. // We will reset the buffer position to the marked position if // there's not enough bytes in the buffer. buffer.markReaderIndex(); int dataLength = getLength(array);// length of the record // wait until the whole data is available. if (buffer.readableBytes() < dataLength) { // The whole bytes were not received yet - return null. // This method will be invoked again when more packets are received // and appended to the buffer. // Reset to the marked position to read the length field again next // time. buffer.resetReaderIndex(); return null; } // forward remaining buffer to higher up handlers // There's enough bytes in the buffer. Read it. ChannelBuffer frame = buffer.readBytes(dataLength); // Successfully decoded a frame. Return the decoded frame. return frame; } /** * Returns the first 2 or 3 sequence of bytes...that specify the length of * the record * * @param array * The byte array containing the length * @return An integer representing the length of the record */ public int getLength(byte[] array) { String temp = new String(array, CharsetUtil.ISO_8859_1); int length = 0; try { length = Integer.parseInt(temp); } catch (Exception ex) { logger.info("Could not parse the length field of the record >>>" + temp); } return length; } }