Time of Update: 2018-07-25
司有個業務需要匹配文本中的網址,度娘,穀哥了半天經常看到有對html中擷取超連結的正則,只要匹配<a href=['"]?(.*?)['"]?即可,但如果是普通文本類型的則比較費事些,分享下最後的運算式: import java.util.regex.Matcher;import java.util.regex.Pattern;public class URLMatcher {public static void main(String[] args)
Time of Update: 2018-07-25
import android.app.Activity;import android.app.AlertDialog;import android.content.DialogInterface;import android.os.Bundle;import android.view.View;import
Time of Update: 2018-07-25
public static void deleteDirFile(String sDirFilePath) { if (sDirFilePath != null && !sDirFilePath.trim().equals("")) { File tDirFile = new File(sDirFilePath); if (tDirFile.exists()) { if (tDirFile.isDirectory()) { File[] arrFiles =
Time of Update: 2018-07-25
找不到基本對象池:“java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool”解決方案 問題: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DataSource' defined in ServletContext resource
Time of Update: 2018-07-25
1)使用指令碼語言的優勢 Rapid turnaround, encouraging experimentation. Changing the behavior of a running program. Enabling customization by program users. 2) The site http://scripting.dev.java.net provides engines for a
Time of Update: 2018-07-25
JDK1.6版添加了新的ScriptEngine類,允許使用者直接執行js代碼。 在Java中直接調用js代碼 不能呼叫瀏覽器中定義的js函數,會拋出異常提示ReferenceError: “alert” is not defined。 package com.sinaapp.manjushri; import javax.script.ScriptEngine; import
Time of Update: 2018-07-25
package cn.com; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import
Time of Update: 2018-07-25
JAVA JDK中的解壓縮似乎不能解壓縮我們手工壓縮的RAR檔案,只能解壓JDK中的API壓縮的RAR 所以想出以下用WINRAR命令列方式的解壓縮 package edu.nwpu.vcampus.util; import java.io.File; public class ZipUtil { public static final String winrarPath = "C://Program Files//WinRAR//WinRAR.exe";
Time of Update: 2018-07-25
btnNewButton.addMouseListener(new MouseAdapter() {public void mouseClicked(MouseEvent e)
Time of Update: 2018-07-25
java中刪除目錄事先要刪除目錄下的檔案或子目錄。用遞迴就可以實現。public void del(String filepath) throws IOException{File f = new File(filepath);//定義檔案路徑 if(f.exists() && f.isDirectory()){//判斷是檔案還是目錄
Time of Update: 2018-07-25
//測試類別 package test; import java.util.List; import org.junit.Test; import sini.dal.rights.GeneralDao; import sini.dal.rights.MenuDao; import sini.dal.rights.impl.GeneralDaoImpl; import sini.dal.rights.impl.ImplFactory; import
Time of Update: 2018-07-25
http://hi.baidu.com/pannijingling/blog/item/28920202733bb7fe09fa936f.html (java)擷取某檔案夾下面所有的指定類型的檔案名稱,並根據情況返回可用的名稱 檢查磁碟上指定目錄是否已經存在同名檔案(本代碼是檢查.jpg檔案類型),存在三種情況: *
Time of Update: 2018-07-25
Proxy 提供用於建立動態代理類和執行個體的靜態方法。簡潔方法:Foo f = (Foo)
Time of Update: 2018-07-25
// 目標字串 取出"!57M" String c = "ptui_checkVC('0','!57M');"; // 正則初始化 Pattern p = Pattern.compile("ptui_checkVC//('.*','(.*)'//);"); // 匹配器初始化 Matcher m = p.matcher(c); // 匹配查詢 while (m.find()) { System.out.println(m.group(1
Time of Update: 2018-07-25
/** * 刪除單個檔案 * @param filePath 被刪除檔案的檔案名稱 * @return 檔案刪除成功返回true,否則返回false */ public boolean deleteFile(String filePath) {
Time of Update: 2018-07-25
自己寫的一個小例子,記錄一下。 package com.lxq.annotationAndreflection;public class Person{String name="default";Integer age=0;public Person(){super();}public Person(String name, Integer age){super();this.name = name;this.age = age;}public String
Time of Update: 2018-07-25
import java.io.Console;import java.io.PrintWriter;public class TestConsole {public static void main(String[] args) {Console cons = System.console();if (cons != null) {// -------------------------PrintWriter printWriter =
Time of Update: 2018-07-25
在使用java來移動檔案時,主要利用IO中的File類,在File類中可以利用renameTo方法實現檔案的移動,執行個體如下: private boolean RemoveFile(String fileName,String destinationFloderUrl) { File file = new File(fileName); File destFloder = new File(destinationFloderUrl);
Time of Update: 2018-07-25
做的程式有時候會需要用到, 記錄下 public class NumberUtil {/** * int整數轉換為4位元組的byte數組 * * @param i * 整數 * @return byte數組 */public static byte[] intToByte4(int i) {byte[] targets = new byte[4];targets[3] = (byte) (i & 0xFF);targets[2] = (byte) (
Time of Update: 2018-07-25
我在公司寫的一個隨機數的工具類,比較實用。 它可以指定字母或數字產生多少位隨機數。 package com.hanyastar.util.o;import java.util.Random;/** * <b>隨機類工具</b> * * @author Belen * @version 1.0 * @since 2013-5-16 */ public abstract