Java之Util工具类

【学习体会】Lighttools8.4.0:软件基本使用+光度学基本概念+系统初始设置 关于Lighttools8.4.0软件的安装教程,详见我的另一篇博文:【软件安装】win10下Lighttools8.4.0(64)光学系统建模软件的安装教程 在本文中,我们将学习到,光度学的基本概念、系统初始设置、物体模型坐标的使用方法、简单光学系统实例、系统浏览器的作用和内容、设置虚拟相机并渲染视图中的图像、仿真结果3D显示等。 如果有其他感兴趣的内容但是我又没有写的,欢迎在评论区留言! 光度学的基本概念 软件的基本介绍 参考博文:https://www.docin.c... 阅读详情
import java.io.*;
import java.lang.management.ManagementFactory;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.sql.*;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;

public class Util {
	private static final Logger log = Logger.getLogger(Util.class.getSimpleName());
	private static final long FILE_COPY_BUFFER_SIZE = 1024 * 1024 * 3;
	private static final String WORDS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	private static final SecureRandom RANDOM = new SecureRandom();
	private static final String UA_Iphone = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25";
	private static final String UA_Firefox = "Firefox/18.0";
	private static final String UA_Chrome = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36";

	private static String P_Email = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";

	public static boolean isNull(String val) {
		return val == null || "".equals(val.trim());
	}

	/**
	 * @TODO 0?
	 * @param val
	 * @return
	 */
	public static Integer getInteger(String val) {
		return isNull(val) ? 0 : Integer.valueOf(val.trim());
	}

	public static Long getLong(String val) {
		return isNull(val) ? 0 : Long.valueOf(val.trim());
	}

	public static Integer getInt(String val) {
		return isNull(val) ? 0 : Integer.parseInt(val.trim());
	}

	public static Double getDouble(String val) {
		return isNull(val) ? 0.0d : Double.valueOf(val.trim());
	}

	public static java.sql.Date getSQLDate(String val) {
		return isNull(val) ? null : java.sql.Date.valueOf(val.trim());
	}

	// is Number
	public static boolean isNumber(String inputData) {
		NumberFormat formatter = NumberFormat.getInstance();
		ParsePosition pos = new ParsePosition(0);
		formatter.parse(inputData, pos);
		return inputData.length() == pos.getIndex();
	}

	public static boolean isInteger(String s) {
		Scanner sc = new Scanner(s);
		return sc.hasNextInt();
	}

	public static boolean isNumeric(String str) {
		if (str == null)
			return false;
		for (char c : str.toCharArray()) {
			if (!Character.isDigit(c))
				return false;
		}
		return true;
	}

	/**
	 * data time <br />
	 * yyyy-MM-dd HH:mm:ss <br />
	 */
	public static String now() {
		String fmt = "yyyy-MM-dd HH:mm:ss";
		SimpleDateFormat df = new SimpleDateFormat(fmt);
		return (df.format(new Date()));
	}

	/** yyyy-MM-dd HH:mm:ss */
	public static String getNowTime() {
		return getNowTime("yyyy-MM-dd HH:mm:ss");
	}

	/** yyyyMMddHHmmss */
	public static Long getNowTimeNumber() {
		return new Long(getNowTime("yyyyMMddHHmmss"));
	}

	/** yyyyMMddHHmmss */
	public static String getNowTimeLong() {
		return getNowTime("yyyyMMddHHmmss");
	}

	/** yyyyMMddHHmmss */
	public static String getNowTimeFile() {
		return getNowTime("yyyyMMddHHmmss");
	}

	public static String getNowTime(String fmt) {
		SimpleDateFormat sf = new SimpleDateFormat(fmt);
		String dt = sf.format(new Date());
		return dt;
	}

	/** yyyyMMddHHmmss */
	public static Long roll2Date(long epoch, long roll2) {
		return roll2Date(epoch, roll2, "yyyyMMddHHmmss");
	}

	public static Long roll2Date(long epoch, long roll2, String fmt) {
		SimpleDateFormat sf = new SimpleDateFormat(fmt);
		String dt = sf.format(new Date(epoch + roll2));
		return new Long(dt);
	}

	/** milliseconds "yyyyMMddHHmmss" */
	public static Long epoch2dateLong(long epoch) {
		return new Long(epoch2date(epoch, "yyyyMMddHHmmss"));
	}

	/** milliseconds "yyyy-MM-dd HH:mm:ss" */
	public static String epoch2date(long epoch) {
		return epoch2date(epoch, "yyyy-MM-dd HH:mm:ss");
	}

	/** yyyy-MM-dd HH:mm:ss */
	public static String epoch2date(long epoch, String fmt) {
		SimpleDateFormat sf = new SimpleDateFormat(fmt);
		String dt = sf.format(new Date(epoch));
		return dt;
	}

	public static long getEpoch() {
		return new Date().getTime() / 1000;
	}

	/** 20160719181054 -> 2016-07-19 18:10:54 */
	public static String showTime(long time) {
		String l = String.valueOf(time);
		return l.substring(0, 4) + "-" + l.substring(4, 6) + "-" + l.substring(6, 8) + " " //
				+ l.substring(8, 10) + ":" + l.substring(10, 12) + ":" + l.substring(12, 14);

	}

	public static String showTimeMinute(long time) {
		return showTime(time).substring(0, 16);
	}

	// ip country
	public static long ip2num(String start_ip) {
		String[] octets_start = start_ip.split("\\.");
		long _start = 0;
		for (String octet_s : octets_start) {
			int octet_i = Integer.parseInt(octet_s);
			_start <<= 8;
			_start |= octet_i;
		}
		return _start;
	}

	public static String num2ip(long ip_number) {
		String[] octets = new String[4];
		for (int i = 3; i >= 0; i--) {
			octets[i] = String.valueOf(ip_number & 0xFF);
			ip_number >>= 8;
		}
		return join(Arrays.asList(octets), ".");
	}

	// binary search
	public static int firstLeft(Long[] array, long k, int start, int end) {
		if (start > end) {
			return -1;
		}
		int c = 0;
		while (start < end) {
			int mid = start + (end - start) / 2;
			if (array[mid] == k) {
				return mid;
			} else if (array[mid] > k) {
				end = mid - 1;
			} else { // [mid] < k
				start = mid + 1;
			}
			// System.out.println("firstLeft(): " + c++ + " " + start);
		}
		if (array[start] > k) {
			return start - 1;
		} else {
			return start;
		}
	}

	/* string */
	public static boolean valid(String obj) {
		return obj != null && !"".equals(obj);
	}

	public static boolean validEmail(String e) {
		if (e == null)
			return false;
		Pattern regex = Pattern.compile(P_Email);
		Matcher matcher = regex.matcher(e);
		return matcher.matches();
	}

	public static String slurp(InputStream in) throws IOException {
		StringBuffer out = new StringBuffer();
		byte[] b = new byte[4096];
		for (int n; (n = in.read(b)) != -1;) {
			out.append(new String(b, 0, n));
		}
		return out.toString();
	}

	public static List<String> split(String line, int len) {
		List<String> l = new ArrayList<String>();
		for (int i = 0; i < line.length(); i += len) {
			l.add(line.substring(i, i + len));
		}
		// return l.toArray(new String[l.size()]);
		return l;
	}

	/** SPACE -> "" */
	public static String[] split(String line, String delimiter) {
		List<String> nodeValues = new ArrayList<String>();

		int offset = 0;
		int pos = line.indexOf(delimiter, offset);

		while (pos != -1) {
			nodeValues.add(offset == pos ? "" : line.substring(offset, pos));

			offset = pos + delimiter.length();
			pos = line.indexOf(delimiter, offset);
		}

		if (offset <= line.length()) {
			nodeValues.add(offset == line.length() ? "" : line.substring(offset));
		}
		return nodeValues.toArray(new String[nodeValues.size()]);
	}

	public static String join(Collection<?> ls, String delimiter) {
		String dl = delimiter == null ? "" : delimiter;
		StringBuilder builder = new StringBuilder();
		for (Object o : ls) {
			builder.append(o).append(dl);
		}
		return builder.substring(0, builder.length() - dl.length());
	}

	public static String join(Object[] ls, String delimiter) {
		String dl = delimiter == null ? "" : delimiter;
		StringBuilder builder = new StringBuilder();
		for (Object o : ls) {
			builder.append(o).append(dl);
		}
		return builder.substring(0, builder.length() - dl.length());
	}

	public static String join(long[] ls, String delimiter) {
		String dl = delimiter == null ? "" : delimiter;
		StringBuilder builder = new StringBuilder();
		for (long o : ls) {
			builder.append(o).append(dl);
		}
		return builder.substring(0, builder.length() - dl.length());
	}

	public static String resetParameter(String url, String param, String value) {
		String rrl = eraseParameter(url, param);
		if (rrl.indexOf('?') != -1) {
			return rrl += "&" + param + "=" + value;
		}
		return rrl += "?" + param + "=" + value;
	}

	public static String eraseParameter(String url, String param) {
		int si = url.indexOf(param + "=");
		if (si != -1) {
			int ei = url.indexOf('&', si);
			if (url.charAt(si - 1) == '&') { // no start
				si -= 1;
			} else if (url.charAt(si - 1) == '?') { // first
				ei += 1;
			}
			return url.substring(0, si) + (ei < 1 ? "" : url.substring(ei));
		}
		return url;
	}

	public static String getParameter(String url, String param) {
		int si = url.indexOf(param + "=");
		if (si != -1) {
			int ei = url.indexOf('&', si);
			if (ei == -1) { // end of url
				ei = url.length();
			}
			return url.substring(si + param.length() + 1, ei);
		}
		return "";
	}

	/** 100000 -> 123456 */
	public static int randomNumber(int base) {
		int r = RANDOM.nextInt(base * 10);
		return r < base ? base + r : r;
	}

	public static String random() {
		return random(32);
	}

	public static String random(int len) {
		StringBuilder sb = new StringBuilder(len);
		int size = WORDS.length();
		for (int i = 0; i < len; i++)
			sb.append(WORDS.charAt(RANDOM.nextInt(size)));
		return sb.toString();
	}

	public static String zeroPrefix(int val, int len) {
		return zeroPrefix(String.valueOf(val), len);
	}

	public static String zeroPrefix(String val, int len) {
		return ("00000000000000000000".substring(0, len) + val).substring(val.length());
	}

	// crc32
	public static long getCRC32(List<String> ls) {
		String[] a = new String[ls.size()];
		return getCRC32(ls.toArray(a));
	}

	public static long getCRC32(String str) {
		return str.hashCode();
	}

	public static long getCRC32(String[] strs) {
		long crc = 0;
		for (String str : strs) {
			if (str == null)
				continue;
			crc ^= str.hashCode();
		}
		return crc;
	}

	/* file and stream */
	public static String getMD5(byte[] bs) {
		try {
			MessageDigest digest = MessageDigest.getInstance("MD5");
			digest.update(bs);
			byte[] md5sum = digest.digest();
			String md5 = "";
			for (int i = md5sum.length - 1; i >= 0; i--) {
				String hex = Integer.toHexString(md5sum[i] & 0xFF);
				if (hex.length() == 1) {
					hex = '0' + hex;
				}
				md5 = hex + md5;
			}
			return md5;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static String getMD5(String s) {
		return s == null ? null : getMD5(s.getBytes());
	}

	public static String getMD5(File f) throws Exception {
		InputStream is = new FileInputStream(f);
		byte[] buffer = new byte[8192];
		int read = 0;
		MessageDigest digest = MessageDigest.getInstance("MD5");
		while ((read = is.read(buffer)) > 0) {
			digest.update(buffer, 0, read);
		}
		is.close();
		byte[] md5sum = digest.digest();

		String md5 = "";
		for (int i = md5sum.length - 1; i >= 0; i--) {
			String hex = Integer.toHexString(md5sum[i] & 0xFF);
			if (hex.length() == 1) {
				hex = '0' + hex;
			}
			md5 = hex + md5;
		}
		return md5;
	}

	public static byte[] hex2byte(String s) {
		int len = s.length();
		byte[] data = new byte[len / 2];
		for (int i = 0; i < len; i += 2) {
			data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
		}
		return data;
	}

	public static Map<String, String> readConfig(String conf) {
		Map<String, String> map = Collections.synchronizedMap(new HashMap<String, String>());

		try {
			// reload conf file
			Properties config = new Properties();
			InputStream ins = new Util().getClass().getResourceAsStream(conf);
			config.load(ins);

			for (Iterator it = config.keySet().iterator(); it.hasNext();) {
				String nam = (String) it.next();
				String val = new String(config.getProperty(nam).getBytes("ISO8859-1"), "UTF-8");
				map.put(nam, val.trim());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return map;
	}

	public static byte[] utf2gbk(byte[] bs) {
		return byteConvert(bs, "UTF-8", "GBK");
	}

	public static byte[] byte2UTF8(byte[] bs, String orgcs) {
		return byteConvert(bs, orgcs, "UTF-8");
	}

	public static byte[] byteConvert(byte[] bs, String orgcs, String dstcs) {
		try {
			Charset org = Charset.forName(orgcs);
			Charset dst = Charset.forName(dstcs);

			ByteBuffer inb = ByteBuffer.wrap(bs);
			CharBuffer data = org.decode(inb);

			ByteBuffer outputBuffer = dst.encode(data);
			byte[] oub = outputBuffer.array();
			return oub;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void checkNnewDir(String fn) {
		try {
			File f = new File(fn);
			File d = f.getParentFile();
			if (!d.exists()) {
				d.mkdirs();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static String getLine(String ctn, int seq) {
		int si = 0;
		int ni = -1;
		do {
			si = ni + 1;
			ni = ctn.indexOf('\n', Math.max(0, si));
			// System.out.println(seq + " " + si + " " + ni);
		} while (--seq > 0 && ni != -1);
		ni = ni == -1 && si < ctn.length() ? ctn.length() : ni;
		return ni != -1 ? ctn.substring(si, ni) : null;
	}

	public static String getNextLine(String ctn, int offset) {
		int ei = ctn.indexOf('\n', offset);
		return ei != -1 && ei > offset ? ctn.substring(offset, ei) : null;
	}

	public static byte[] streamReader(InputStream ins) throws IOException {
		return streamReader(ins, 0, -1);
	}

	public static byte[] streamReader(InputStream ins, long skip, long size) throws IOException {
		BufferedInputStream bis = new BufferedInputStream(ins);
		bis.skip(skip); // 0 or +

		boolean hasSize = size != -1; // -1 full
		long readed = 0;

		ByteArrayOutputStream ba = new ByteArrayOutputStream();
		long bsize = hasSize ? Math.min(1024, size) : 1024;
		byte[] b = new byte[(int) bsize];
		int len = 0;
		while ((len = bis.read(b)) != -1) {
			ba.write(b, 0, len);

			if (hasSize) {
				readed += len;
				if (size - readed < 1024) {
					b = new byte[(int) (size - readed)];
				}
				if (readed == size) {
					break;
				}
			}
		}
		return ba.toByteArray();
	}

	public static byte[] stream2array(InputStream ins) {
		return stream2array(ins, 20480);
	}

	public static byte[] stream2array(InputStream ins, int bsize) {
		ByteArrayOutputStream out = new ByteArrayOutputStream(bsize);
		try {
			byte[] buf = new byte[bsize];
			int len;
			while ((len = ins.read(buf)) > 0) {
				out.write(buf, 0, len);
			}
			ins.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return out.toByteArray();
	}

	// file to byte[]
	public static byte[] getBytesFromFile(File file) {
		try {
			InputStream is = new FileInputStream(file);

			// Get the size of the file
			long length = file.length();

			// You cannot create an array using a long type.
			// It needs to be an int type.
			// Before converting to an int type, check
			// to ensure that file is not larger than Integer.MAX_VALUE.
			if (length > Integer.MAX_VALUE) {
				// File is too large
			}

			// Create the byte array to hold the data
			byte[] bytes = new byte[(int) length];

			// Read in the bytes
			int offset = 0;
			int numRead = 0;
			while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
				offset += numRead;
			}

			// Ensure all the bytes have been read in
			if (offset < bytes.length) {
				throw new IOException("Could not completely read file " + file.getName());
			}

			// Close the input stream and return bytes
			is.close();
			return bytes;
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
		return null;
	}

	public static byte[] getBytesFromUrl(String url) throws IOException {
		return getBytesFromUrl(url, 0);
	}

	public static byte[] getBytesFromUrl(String url, int size) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream(1024 * 20);
		BufferedInputStream in = new BufferedInputStream(new URL(url).openStream());

		byte[] b = new byte[1024];
		int sz = 0;
		int siz_ = 0;
		while ((sz = in.read(b)) != -1) {
			out.write(b, 0, sz);
			siz_ += sz;
			if (size > 0 && siz_ >= size) {
				break;
			}
		}
		in.close();
		return out.toByteArray();
	}

	public static byte[] getBytesOfUrl(String u) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream(1024 * 20);
		URL url = new URL(u);
		HttpURLConnection con = (HttpURLConnection) url.openConnection();
		HttpURLConnection.setFollowRedirects(true);
		con.setConnectTimeout(1000 * 5);
		con.setRequestProperty("User-Agent", UA_Chrome);
		con.setRequestMethod("GET");

		// Map<String, List<String>> responseMap = con.getHeaderFields();
		// for (Iterator<String> iterator = responseMap.keySet().iterator(); iterator.hasNext();) {
		// String key = (String) iterator.next();
		// List<String> values = responseMap.get(key);
		// for (int i = 0; i < values.size(); i++) {
		// Object o = values.get(i);
		// System.out.println(key + ": " + o);
		// }
		// }

		InputStream is = con.getInputStream();
		BufferedInputStream bis = new BufferedInputStream(is);
		byte[] buf = new byte[1024];
		int len = -1;
		while ((len = bis.read(buf)) != -1) {
			out.write(buf, 0, len);
		}
		bis.close();
		return out.toByteArray();
	}

	public static byte[] deGZip(byte[] gz) throws IOException {
		return deGZip(gz, 1024 * 1024 * 1);
	}

	public static byte[] deGZip(byte[] gz, int bsize) throws IOException {
		GZIPInputStream gs = new GZIPInputStream(new ByteArrayInputStream(gz));
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		int len = 0;
		byte[] buf = new byte[bsize];
		while ((len = gs.read(buf)) != -1) {
			baos.write(buf, 0, len);
		}
		return baos.toByteArray();
	}

	/* exception */
	public static byte[] getExceptionTrace(Exception e) {
		ByteArrayOutputStream ba = new ByteArrayOutputStream();
		PrintStream w = new PrintStream(ba);
		e.printStackTrace(w);
		w.flush();
		return ba.toByteArray();
	}

	/* sql */
	public static String getCountSql(String sql) {
		StringBuilder sb = new StringBuilder();
		int fi = sql.indexOf(" from ");
		sb.append("select count(1)");
		sb.append(sql.substring(fi));
		return sb.toString();
	}

	public static String getPagingSqlMySQL(String sql, int start, int stop) {
		return sql + " limit " + (start >= 1 ? start - 1 : start) + ", " + (stop > start ? (stop - start) + 1 : 1);
	}

	public static String getPagingSql(String sql, int start, int stop) {
		StringBuilder sb = new StringBuilder();
		int wi = sql.lastIndexOf(" where ");
		boolean hw = (wi != -1 && sql.substring(wi).indexOf(')') == -1);
		String wr = hw ? " and" : " where";
		sb.append("select * from (select rownum as num, ");
		sb.append(sql.substring(7));
		sb.append(wr);
		sb.append(" rownum <= ");
		sb.append(stop);
		sb.append(") t where t.num >= ");
		sb.append(start);
		return sb.toString();
	}

	/** seq_acct_id -> ACCT */
	public static String getSequencePref(String seq) {
		int si = seq.indexOf('_') + 1;
		int ei = seq.indexOf('_', si);
		return seq.substring(si, ei).toUpperCase();
	}

	public static void closeConnection(Connection conn) {
		try {
			if (conn != null) {
				// log.info("auto commit(" + conn.getAutoCommit() + ")");
				if (!conn.getAutoCommit()) {
					conn.setAutoCommit(true);
				}
				conn.close();
			}
			conn = null;
		} catch (SQLException se) {
			se.printStackTrace();
		}
	}

	public static void rollbackConnection(Connection conn) {
		try {
			if (conn != null) {
				log.info("rollbackConnection(" + conn.getAutoCommit() + ")");
				conn.rollback();
			}
		} catch (SQLException se) {
			se.printStackTrace();
		}
	}

	public static void closeStatement(Statement stmt) {
		try {
			if (stmt != null) {
				stmt.close();
			}
		} catch (SQLException se) {
			se.printStackTrace();
		}
	}

	public static void closeResultSet(ResultSet rs) {
		try {
			if (rs != null) {
				rs.close();
			}
		} catch (SQLException se) {
			se.printStackTrace();
		}
	}

	public static void closeRS(ResultSet rs, Statement stmt) {
		closeResultSet(rs);
		closeStatement(stmt);
	}

	public static void closeRSC(ResultSet rs, Statement stmt, Connection conn) {
		closeResultSet(rs);
		closeStatement(stmt);
		closeConnection(conn);
	}

	public static void ShowResultSetMeta(ResultSetMetaData md) {
		try {
			int cc = md.getColumnCount();
			for (int i = 1; i <= cc; i++) {
				String name = md.getColumnName(i);
				String type = md.getColumnTypeName(i);
				log.info("ShowResultSetMeta(): " + name + ", " + type);
			}
		} catch (SQLException se) {
			se.printStackTrace();
		}
	}

	public static boolean validConnection(Connection conn) {
		boolean valid = false;
		try {
			valid = conn != null && !conn.isClosed() && conn.isValid(3);
		} catch (SQLException se) {
			valid = false;
		} finally {
			if (!valid) {
				closeConnection(conn);
			}
		}
		return valid;
	}

	public static void printSQLException(SQLException ex) {
		for (Throwable e : ex) {
			if (e instanceof SQLException) {
				e.printStackTrace(System.err);
				System.err.println("SQLState: " + ((SQLException) e).getSQLState());
				System.err.println("Error Code: " + ((SQLException) e).getErrorCode());
				System.err.println("Message: " + e.getMessage());
				Throwable t = ex.getCause();
				while (t != null) {
					System.out.println("Cause: " + t);
					t = t.getCause();
				}
			}
		}
	}

	/** http */
	public static String httpPost(String url, String data) {
		return httpPost(url, data, 0);
	}

	public static String httpPost(String url, String data, int timeout) {
		String charset = "UTF-8";
		OutputStream output = null;
		try {
			HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
			conn.setDoOutput(true); // Triggers POST.
			conn.setDoInput(true);
			conn.setRequestMethod("POST"); // POST method
			conn.setRequestProperty("Accept-Charset", charset);
			conn.setRequestProperty("Connection", "keep-alive");
			conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
			conn.setUseCaches(false);
			conn.setConnectTimeout(timeout == 0 ? 5000 : timeout);

			output = conn.getOutputStream();
			output.write(data.getBytes());

			int status = conn.getResponseCode();
			InputStream response = conn.getInputStream();
			String rs = new String(Util.streamReader(response));
			return rs != null ? rs.trim() : null;
		} catch (IOException ie) {
			ie.printStackTrace();
			return "-1";
		} finally {
			if (output != null)
				try {
					output.close();
				} catch (IOException logOrIgnore) {
				}
		}
	}

	/** security */
	public static final String encrypt(String data, BigInteger confuse) {
		if (data == null || data.length() == 0)
			return null;

		BigInteger bi_passwd = new BigInteger(data.getBytes());
		BigInteger bi_r1 = confuse.xor(bi_passwd);
		return bi_r1.toString(Character.MAX_RADIX);
	}

	public static final String decrypt(String encrypted, BigInteger confuse) {
		if (encrypted == null || encrypted.length() == 0)
			return null;

		try {
			BigInteger bi_r1 = new BigInteger(encrypted, Character.MAX_RADIX);
			BigInteger bi_r0 = bi_r1.xor(confuse);
			return new String(bi_r0.toByteArray());
		} catch (Exception e) {
			return null;
		}
	}

	public static final String rot13(String s) {
		StringBuilder b = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c >= 'a' && c <= 'm')
				c += 13;
			else if (c >= 'A' && c <= 'M')
				c += 13;
			else if (c >= 'n' && c <= 'z')
				c -= 13;
			else if (c >= 'N' && c <= 'Z')
				c -= 13;
			b.append(c);
		}
		return b.toString();
	}

	public static int byte2int(byte[] b) {
		if (b.length == 4)
			return b[0] << 24 | (b[1] & 0xff) << 16 | (b[2] & 0xff) << 8 | (b[3] & 0xff);
		if (b.length == 3)
			return 0x00 << 24 | (b[0] & 0xff) << 16 | (b[1] & 0xff) << 8 | (b[2] & 0xff);
		else if (b.length == 2)
			return 0x00 << 24 | 0x00 << 16 | (b[0] & 0xff) << 8 | (b[1] & 0xff);
		else if (b.length == 2)
			return 0x00 << 24 | 0x00 << 16 | 0x00 << 8 | (b[0] & 0xff);
		return 0;
	}

	public static byte[] int2byte(int value) {
		byte[] array = new byte[4];
		int offset = 0;
		array[offset] = (byte) (0xff & (value >> 24));
		array[offset + 1] = (byte) (0xff & (value >> 16));
		array[offset + 2] = (byte) (0xff & (value >> 8));
		array[offset + 3] = (byte) (0xff & value);
		return array;
	}

	public static boolean fileTouch(String f) {
		File file = new File(f);
		try {
			file.createNewFile();
			if (file.exists()) {
				return file.setLastModified(System.currentTimeMillis());
			}
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
		return false;
	}

	public static boolean fileDelete(String f) {
		File file = new File(f);
		try {
			return file.delete();
		} catch (Exception ignored) {
			return false;
		}
	}

	public static boolean fileCopy(String f_src, String f_dest) throws IOException {
		File srcFile = new File(f_src);
		File destFile = new File(f_dest);

		FileInputStream fis = null;
		FileOutputStream fos = null;
		FileChannel input = null;
		FileChannel output = null;
		try {
			fis = new FileInputStream(srcFile);
			fos = new FileOutputStream(destFile);
			input = fis.getChannel();
			output = fos.getChannel();
			long size = input.size();
			long pos = 0;
			long count = 0;
			while (pos < size) {
				count = size - pos > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : size - pos;
				pos += output.transferFrom(input, pos, count);
			}
		} finally {
			output.close();
			fos.close();
			input.close();
			fis.close();
		}

		if (srcFile.length() != destFile.length()) {
			return false;
		}
		return true;
	}

	public static void fileSave(String f, byte[] ctn) {
		OutputStream out;
		try {
			out = new FileOutputStream(f);
			out.write(ctn);
			out.flush();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static String getJavaPID() {
		String pid = ManagementFactory.getRuntimeMXBean().getName();
		int ati = pid.indexOf('@');
		if (ati != -1)
			pid = pid.substring(0, ati);
		return pid;
	}

	public static long getIntegerOfArray(byte[] array, int offset) {
		return ((0xff & array[offset + 0]) << 0) | ((0xff & array[offset + 1]) << 8) | ((0xff & array[offset + 2]) << 16) | ((0xff & array[offset + 3]) << 24);
	}

	// Note: Value needs to be long to avoid sign extension
	public static void setIntegerToArray(byte[] array, int offset, long value) {
		array[offset + 0] = (byte) ((value >> 0) & 0xff);
		array[offset + 1] = (byte) ((value >> 8) & 0xff);
		array[offset + 2] = (byte) ((value >> 16) & 0xff);
		array[offset + 3] = (byte) ((value >> 24) & 0xff);
	}

	public static byte[] mergeArray(byte[] a1, byte[] a2) {
		byte[] a = new byte[a1.length + a2.length];
		System.arraycopy(a1, 0, a, 0, a1.length);
		System.arraycopy(a2, 0, a, a1.length, a2.length);
		return a;
	}

	public static int[] mergeArray(int[] a1, int[] a2) {
		int[] a = new int[a1.length + a2.length];
		System.arraycopy(a1, 0, a, 0, a1.length);
		System.arraycopy(a2, 0, a, a1.length, a2.length);
		return a;
	}

	/**
	 * String t = "asd asdf fa ab|\"ce asdf\"|eifw234 \"asdf adsf sadf\""; <br />
	 */
	public static String[] getTerms(String t) {
		if (t == null)
			return null;
		t = t.trim().replaceAll("\\s+", " ");

		List<String> ts = new ArrayList<String>();
		int t0 = 0;
		boolean g0 = false;
		boolean g1 = false;
		for (int i = 0; i < t.length(); i++) {
			if (t.charAt(i) == ' ' && (!g0 || (g0 && g1))) {
				ts.add(t.substring(t0, i).replaceAll("\"", ""));
				t0 = i + 1;
				if (g0 && g1) {
					g0 = false;
					g1 = false;
				}
			}
			if (t.charAt(i) == '"') {
				if (g0)
					g1 = true;
				else
					g0 = true;

				if (g0 && g1 && t.length() > i + 1 && t.charAt(i + 1) == '|') {
					g0 = false;
					g1 = false;
				}
			}
		}
		ts.add(t.substring(t0).replaceAll("\"", ""));
		String[] terms = new String[ts.size()];
		ts.toArray(terms);

		return terms;
	}
}

记录一个util工具类,类中有一些生成随机数,以及根据url获取请求的设备类型等方法。

倍福PLC--PERSISTENT断电保持数据和BOOT中各文件对应的解析 将D:\TC3程序\TwinCAT Project146\TwinCAT RT(x86)\Plc 文件夹的中三个替换文件复制到:G:\TwinCAT\3.1\Boot\Plc完成替换,如下图。(2) 找到程序所存的路径,编程电脑的D:\TC3程序\TwinCAT Project146路径下,并选择对应系统平台TwinCAT RT(x86)(3) 控制器断电,拔出内存卡,使用读卡器,在编程电脑中打开:(本次测试读卡器为G盘)(5) 开机完成后,TwinCAT自动运行,当前闪灯频率为50ms。 阅读详情

相关推荐

【Verilog】valid-ready双向握手机制 ——很绕但是很有意思

valid-ready双向握手机制。

GalaxyerKw的博客 1万+

java 利用ManagementFactory获取jvm,os的一些信息

java 利用ManagementFactory获取jvm,os的一些信息的代码例子

夢の殇 1万+

【WiFi软件开发】IOCTL和Netlink----用户空间和内核空间交互的两种方式

linux开发中通常会涉及用户空间和内核模块的交互。本文介绍了两种典型的用户空间和内核模块通信方式:ioctl和netlink

liuwe1ye的博客 2347

常用的Java Util工具类

常用的Java Util工具类 #java.common.util-api-1.8 业界有句话:不重复造轮子。 使用工具类可以减少日常繁琐的编码,减少重复的编码时间,提高开发效率。 作为程序员,应该多善于利用工具减少代码冗余,美化自己的代码。 git地址:https:...

星辰大数据的博客 2047

Ubuntu配置Qt Creator树莓派交叉编译环境一步到位

本文详细指导在Ubuntu系统上配置Qt Creator树莓派交叉编译环境。从工具链安装、sysroot创建到Qt库编译,逐步讲解如何搭建完整的ARMv7交叉编译工具链,实现高效开发树莓派应用。

1272

XIAO ESP32S3 Sense摄像头与麦克风实战:从硬件连接到AI语音视觉项目

本文详细介绍了如何使用Seeed Studio XIAO ESP32S3 Sense开发板进行AI语音视觉项目开发。从硬件连接到Arduino环境搭建,再到摄像头拍照、视频流传输、麦克风录音等实战操作,最后引导读者探索基于TensorFlow Lite Micro的语音唤醒和SenseCraft AI的图像识别等AI应用,为物联网和边缘AI项目提供了完整的入门指南。

xray4的博客 1021

Wend看源码-Java.util 工具类学习(上)

本文汇总了基于JDK 21版本的Java.util包中各类工具类的学习与运用指南。旨在为广大开发者提供一份详尽的中文参考资料,以及具体的应用示例,助力开发者更好地掌握和运用这些工具类。其中 Wend看源码-Java.util 工具类学习(上)篇主要介绍的是java.util 包下的工具类。而Wend看源码-Java.util 工具类学习(下)篇主要介绍的是java.util子包,如java.util.concurrent 下的工具类,并包含一些过时工具类的介绍。

wend的博客 1429

ADS系列之SI&PI仿真笔记:ADS多种版本的安装、卸载&重装(一)

此系列仅作为ADS学习过程的记录,如有错误的地方还请大佬指正! 一、下载&安装 ADS软件下载&安装还算比较简单,目前接触到有两个版本:ADS2017和ADS2019。这里贴下链接,破解教程里面都有: ADS2017下载地址:https://pan.baidu.com/s/1l-Bs9owKRmp5Pv0Mt92OYA 提取码:wuzf ADS2019下载地址:吴川斌的博客-w...

Claudedy的博客 3万+

JAVA-Util工具类

Util Random类 Random类用来生成随机数字。使用起来也是三个步骤: 导包 import java.util.Random; 创建 Random r = new Random(); // 小括号当中留空即可 使用 获取一个随机的int数字(范围是int所有范围,有正负两种):int num = r.nextInt() 获取一个随机的int数字(参数代表了范围,左闭右开区间)...

huotong 490

2 中望CAD二次开发-绘制图形(ZRX C++)

本文讲解中望CAD二次开发,关于块的概念及基本图形的绘制

cilvsuanna的博客 410

使用cmd命令查看电脑是不是翻新机 如何查看自己电脑是不是翻新机

最近pdd啥的百亿补贴啊,什么品牌店啊,很多“假一赔十”,绝对“正品”都蹦出来了,很多人拿到以后,也上网查了各种鉴别方式,包括区分是不是翻新机之类的。本人亲自踩坑“pdd品牌店”,“假一赔十”,“绝对正品”等店铺,跟大家分享一下我得鉴别经验(说道分享鉴别经验了,大家也就不用好奇了,我肯定是买到翻新机了,mmp)。 第一步:准备好手机,开始录屏,没有完整的拆箱视频,可能不容易退货退款 第二步:拆箱,查看屏幕划痕(用手机闪光灯看,要不然看不清),然后查看屏幕有没有被擦过的痕迹 第三步:查看USB孔等插口有没有划

weixin_39417324的博客 1万+

Wend看源码-Java.util 工具类学习(下)

本文汇总了基于JDK 21版本的Java.util包中各类工具类的学习与运用指南。旨在为广大开发者提供一份详尽的中文参考资料,以及具体的应用示例,助力开发者更好地掌握和运用这些工具类。其中 Wend看源码-Java.util 工具类学习(上)篇主要介绍的是java.util 包下的工具类。而Wend看源码-Java.util 工具类学习(下)篇主要介绍的是java.util子包,如java.util.concurrent 下的工具类,并包含一些过时工具类的介绍。

wend的博客 1344

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

java.util.Objects工具类示例

java.util.Objects是java 1.7引入的,主要是对对象的一些常用操作,比如compare、equals/deepEquals、hash/hashCode、isNull/nonNull、requiredNonNull、toString这12个常用方法。 Student类 public class Student { private String name; private...

yamaxifeng_132的专栏 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

【数组(java.util.Arrays)工具类使用】

import java.util.Arrays; public class TestArrays1 { public static void main(String[] args) { int[] a={100,20,30,503,666}; System.out.println(a); System.out.println(Arrays.toString(a)); //打印数组内容 Arrays.sort(a); //排序 System.out.printl

RSssr的博客 249

【Objects】java.util.Objects工具类总结

java.util.Objects工具类总结注意是Objects不是Object!认识常用方法 注意是Objects不是Object! 认识 Objects是java.util包下的类,它是java.lang.Object的子类; 包含static实用程序方法,用于操作对象或在操作前检查某些条件 主要是检查操作 这些实用程序包括null或null方法,用于计算对象的哈希代码,返回对象的字符串,比较两个对象,以及检查索引或子范围值是否超出范围。 以下结果正确吗? public class Demo2 {

A-Itfuture的博客 570

深入探索java.util.Objects工具类

Java 的 Objects 类是一个实用工具类,包含了一系列静态方法,用于处理对象。它位于 java.util 包中,自 Java 7 引入。Objects 类的主要目的是降低代码中的空指针异常(NullPointerException) 风险,同时提供一些非常实用的方法供我们使用。

SevenCoding的博客 1451

JDK框架简析--java.util包中的工具类库

在本节中,简析java.util包所包含的工具类库,主要是集合相关的类库,其次还有正则、压缩解压、并发、日期时间等工具类。

Java之旅 5679

Java.util.Arrays 工具类的使用

1 package Test; 2 3 import java.util.Arrays; 4 5 /*** 6 * Java.util.Arrays工具类的使用. 7 * @author 小王同学 8 * 重点:对对象进行排序时,首先要实现comparable接口中的compareTo方法。 9 * 才能对对象数组进行排序...

weixin_30466953的博客 128

java.util.Collections 集合工具类

java.util.Collection 集合接口 java.util.Collections 集合工具类,方便集合的操作 注意:对List集合中的元素排序,需要保证List集合中的元素实现了:Comparable接口 对set集合如何排序呢? 将set集合转换成List集合 package Mapiiiiii; import java.util.*; /* java.util.Collection 集合接口 java.util.Collections 集合工具类,方便集合的操作 */ public c

qq_57935389的博客 1455

JDK工具类_____java.util.loggingLogger

import java.util.logging.Logger; /** * @author Administrator jdk日志操作工具类 */ public class JdkLog { public static Logger logger = Logger.getLogger(JdkLog.class.getName()); public static void getjdk

548

java base64utils_【Java-API工具类】Base64Util类

Base64Util:https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72Base64Util工具类package com.baidu.ai.aip.utils;/*** Base64 工具类*/public class Base64Util {private static final char last2byte = (char) ...

weixin_26759093的博客 314

Java常用类-----java.util.Objects工具类详解

java.util.Objects工具类详解简介Objects 与 Object 区别构造函数常用方法equalsdeepEquals 简介 Objects 与 Object 区别 Object 是 Java 中所有类的基类,位于java.lang包。 Objects 是 Object 的工具类,位于java.util包。   java.util.Objects由 Java 7 引入的 ,包含static实用程序方法,用于操作对象或在操作前检查某些条件。   需要注意的是:这个类用关键字final修饰不

weixin_41758106的博客 5053

【工具类】Java开发常用Util工具类

经常配合上一个使用,下载的压缩包解压为文件然后解码。将GBK编码的文件转为UTF-8编码的文件。用到的maven坐标。

DreamSun的博客 739

java base64utils_Base64Util 工具类

package com.org.utils;import java.io.ByteArrayOutputStream;public class Base64Util {private static final char[] base64EncodeChars = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', ...

weixin_39845825的博客 418

Java提供了哪些常用的工具类,java.util包的工具类总览

包是Java标准库中非常重要的一个包,它提供了大量用于处理数据结构、日期时间、随机数生成、集合操作等的工具类。下面是根据功能分类整理的。是一个独立的包,但它与。

横竖撇折点 799

java.util.Collections工具类方法概览

本文以JDK1.8的Collections源码进行解析 一、引言 java.util.Collections工具类提供了很多操作集合的方法,如果你还不了解这些方法的具体作用,那么了解其使用方法还是很有必要,可以有效的简化代码和增加其可读性 Collections类中的方法可分为一下几种类型: 1、搜索集合: 二分搜索元素: //将List集合对key进行二分搜索,返回key的下标 pu...

APlus 867

util java_Java开发常用Util工具类

MyStringUtil、MyCastUtil、MyCollectionUtil、MyArrayUtil、MyPropsUtil一、字符串工具类MyStringUtiljava内部提供了一个实用工具类-------> StringUtils 不做详细表述这里MyStringUtil/*** StringUtil* @description: 字符串工具类**/public classMyS...

weixin_42350163的博客 782
上一篇: Error Status : -1.OSS can not connect to your callbackUrl, please check it
下一篇: Mac-postman存储文件目录
NatChan
博客等级 码龄9年 12粉丝 26原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值