⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.java

📁 source code for fishnet
💻 JAVA
字号:
import java.io.UnsupportedEncodingException;/** * <pre>    * Provides some useful static methods * </pre>    */public class Utility {        private static final String CHARSET = "US-ASCII";    /**     * Return System time in microseconds     */    public static long fishTime() { 	return System.currentTimeMillis() * 1000;    }    /**     * Convert a string to a byte[]     * @param msg The string to convert     * @return The byte[] that the string was converted to     */    public static byte[] stringToByteArray(String msg) {	try {	    return msg.getBytes(CHARSET);		}catch(UnsupportedEncodingException e) {	    System.err.println("Exception occured while converting string to byte array. String: " + msg + " Exception: " + e);	}	return null;    }        /**     * Convert a byte[] to a string     * @param msg The byte[] to convert      * @return The converted String     */    public static String byteArrayToString(byte[] msg) {	try {	    return new String(msg, CHARSET);	}catch(UnsupportedEncodingException e) {	    System.err.println("Exception occured while converting byte array to string. Exception: " + e);	}	return null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -