Optimized code
This commit is contained in:
@@ -20,7 +20,6 @@ public class PrintMatrixClockWisely {
|
|||||||
* 当前矩阵,最后 1 行 坐标 (start,columns-1-start+1) => (start,endX-1)
|
* 当前矩阵,最后 1 行 坐标 (start,columns-1-start+1) => (start,endX-1)
|
||||||
* 当前矩阵,第 1 行 坐标 (start+1,columns-1+1) => (start+1,endY-1)
|
* 当前矩阵,第 1 行 坐标 (start+1,columns-1+1) => (start+1,endY-1)
|
||||||
*
|
*
|
||||||
* @author WangSai
|
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
2
src/main/java/me/ehlxr/cache/Cache.java
vendored
2
src/main/java/me/ehlxr/cache/Cache.java
vendored
@@ -17,8 +17,6 @@ package me.ehlxr.cache;
|
|||||||
* Company:
|
* Company:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Deepblue 2008-11-11
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
*/
|
||||||
public class Cache {
|
public class Cache {
|
||||||
private String key;// 缓存ID
|
private String key;// 缓存ID
|
||||||
|
|||||||
24
src/main/java/me/ehlxr/cache/CacheManager.java
vendored
24
src/main/java/me/ehlxr/cache/CacheManager.java
vendored
@@ -1,6 +1,8 @@
|
|||||||
package me.ehlxr.cache;
|
package me.ehlxr.cache;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,11 +23,9 @@ import java.util.Map.Entry;
|
|||||||
* Company:
|
* Company:
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Deepblue 2008-11-11
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
*/
|
||||||
public class CacheManager {
|
public class CacheManager {
|
||||||
private static HashMap<String, Object> cacheMap = new HashMap<String, Object>();
|
private static final HashMap<String, Object> cacheMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
// 单实例构造方法
|
// 单实例构造方法
|
||||||
private CacheManager() {
|
private CacheManager() {
|
||||||
@@ -55,7 +55,7 @@ public class CacheManager {
|
|||||||
try {
|
try {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
key = (String) entry.getKey();
|
key = entry.getKey();
|
||||||
if (key.startsWith(type)) { // 如果匹配则删除掉
|
if (key.startsWith(type)) { // 如果匹配则删除掉
|
||||||
arr.add(key);
|
arr.add(key);
|
||||||
}
|
}
|
||||||
@@ -118,11 +118,9 @@ public class CacheManager {
|
|||||||
}
|
}
|
||||||
long nowDt = System.currentTimeMillis(); // 系统当前的毫秒数
|
long nowDt = System.currentTimeMillis(); // 系统当前的毫秒数
|
||||||
long cacheDt = cache.getTimeOut(); // 缓存内的过期毫秒数
|
long cacheDt = cache.getTimeOut(); // 缓存内的过期毫秒数
|
||||||
if (cacheDt <= 0 || cacheDt > nowDt) { // 过期时间小于等于零时,或者过期时间大于当前时间时,则为FALSE
|
// 过期时间小于等于零时,或者过期时间大于当前时间时,则为FALSE
|
||||||
return false;
|
// 大于过期时间 即过期
|
||||||
} else { // 大于过期时间 即过期
|
return cacheDt > 0 && cacheDt <= nowDt;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取缓存中的大小
|
// 获取缓存中的大小
|
||||||
@@ -138,7 +136,7 @@ public class CacheManager {
|
|||||||
try {
|
try {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
key = (String) entry.getKey();
|
key = entry.getKey();
|
||||||
if (key.indexOf(type) != -1) { // 如果匹配则删除掉
|
if (key.indexOf(type) != -1) { // 如果匹配则删除掉
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
@@ -157,7 +155,7 @@ public class CacheManager {
|
|||||||
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
a.add((String) entry.getKey());
|
a.add(entry.getKey());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
@@ -172,7 +170,7 @@ public class CacheManager {
|
|||||||
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
Iterator<Entry<String, Object>> i = cacheMap.entrySet().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Entry<String, Object> entry = i.next();
|
Entry<String, Object> entry = i.next();
|
||||||
key = (String) entry.getKey();
|
key = entry.getKey();
|
||||||
if (key.indexOf(type) != -1) {
|
if (key.indexOf(type) != -1) {
|
||||||
a.add(key);
|
a.add(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,11 @@
|
|||||||
package me.ehlxr.pack;
|
package me.ehlxr.pack;
|
||||||
|
|
||||||
import java.awt.Component;
|
import javax.swing.*;
|
||||||
import java.awt.Point;
|
import java.awt.*;
|
||||||
import java.awt.Rectangle;
|
import java.io.*;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
|
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
private static int sumError = 0;
|
private static int sumError = 0;
|
||||||
private static int sumExistError = 0;
|
private static int sumExistError = 0;
|
||||||
@@ -29,7 +15,7 @@ public class FileUtil {
|
|||||||
|
|
||||||
private static String getDate(Date date) {
|
private static String getDate(Date date) {
|
||||||
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
return sd.format(date).toString();
|
return sd.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedReader getBufferedReader(String path) throws FileNotFoundException {
|
private static BufferedReader getBufferedReader(String path) throws FileNotFoundException {
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
package me.ehlxr.pack;
|
package me.ehlxr.pack;
|
||||||
|
|
||||||
import java.awt.Color;
|
import javax.swing.*;
|
||||||
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
import javax.swing.filechooser.FileSystemView;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.JTextPane;
|
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
import javax.swing.filechooser.FileSystemView;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class PackView extends JFrame {
|
public class PackView extends JFrame {
|
||||||
private JButton jb = new JButton();
|
private final JButton jb = new JButton();
|
||||||
private JButton jb1 = new JButton();
|
private final JButton jb1 = new JButton();
|
||||||
private JButton jb2 = new JButton();
|
private final JButton jb2 = new JButton();
|
||||||
private String inputPath = "D:\\wins-dsp";
|
private final JLabel jl0 = new JLabel();
|
||||||
private String outputPath = "C:\\Users\\ehlxr\\Desktop";
|
private final JButton cancel = new JButton("退出");
|
||||||
private JLabel jl0 = new JLabel();
|
private final JTextPane jText1 = new JTextPane();
|
||||||
private JButton cancel = new JButton("退出");
|
private final JTextPane jText2 = new JTextPane();
|
||||||
private JTextPane jText1 = new JTextPane();
|
|
||||||
private JTextPane jText2 = new JTextPane();
|
|
||||||
public JTextArea jArea = new JTextArea();
|
public JTextArea jArea = new JTextArea();
|
||||||
public JScrollPane p = new JScrollPane(this.jArea);
|
public JScrollPane p = new JScrollPane(this.jArea);
|
||||||
|
private String inputPath = "D:\\wins-dsp";
|
||||||
|
private String outputPath = "C:\\Users\\ehlxr\\Desktop";
|
||||||
|
|
||||||
private PackView() {
|
private PackView() {
|
||||||
setTitle("打包工具(By:Henry)");
|
setTitle("打包工具(By:Henry)");
|
||||||
@@ -149,6 +142,10 @@ public class PackView extends JFrame {
|
|||||||
setDefaultCloseOperation(3);
|
setDefaultCloseOperation(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new PackView();
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> chooseFile(int chooseMode) {
|
private List<String> chooseFile(int chooseMode) {
|
||||||
try {
|
try {
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
@@ -162,10 +159,7 @@ public class PackView extends JFrame {
|
|||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((f.getName().endsWith(".TXT")) || (f.getName().endsWith(".txt"))) {
|
return (f.getName().endsWith(".TXT")) || (f.getName().endsWith(".txt"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
@@ -188,7 +182,7 @@ public class PackView extends JFrame {
|
|||||||
if (returnVal == 0) {
|
if (returnVal == 0) {
|
||||||
fileName = fileChooser.getSelectedFiles();
|
fileName = fileChooser.getSelectedFiles();
|
||||||
} else {
|
} else {
|
||||||
fileName = (File[]) null;
|
fileName = null;
|
||||||
}
|
}
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
System.out.println("打包文件路径列表:");
|
System.out.println("打包文件路径列表:");
|
||||||
@@ -255,7 +249,7 @@ public class PackView extends JFrame {
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < fileName.size(); i++) {
|
for (int i = 0; i < fileName.size(); i++) {
|
||||||
try {
|
try {
|
||||||
flag = FileUtil.becomePackage((String) fileName.get(i), this.inputPath, this.outputPath, this);
|
flag = FileUtil.becomePackage(fileName.get(i), this.inputPath, this.outputPath, this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -263,8 +257,4 @@ public class PackView extends JFrame {
|
|||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new PackView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
* @since 2019-07-19.
|
* @since 2019-07-19.
|
||||||
*/
|
*/
|
||||||
public class RateBarrier {
|
public class RateBarrier {
|
||||||
private AtomicInteger op = new AtomicInteger(0);
|
private final AtomicInteger op = new AtomicInteger(0);
|
||||||
private List<Integer> source;
|
private List<Integer> source;
|
||||||
private int base;
|
private int base;
|
||||||
private int rate;
|
private int rate;
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
package me.ehlxr.sftp;
|
package me.ehlxr.sftp;
|
||||||
|
|
||||||
|
import com.jcraft.jsch.*;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.jcraft.jsch.Channel;
|
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
|
||||||
import com.jcraft.jsch.JSch;
|
|
||||||
import com.jcraft.jsch.Session;
|
|
||||||
import com.jcraft.jsch.SftpException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SFTP工具类
|
* SFTP工具类
|
||||||
*
|
*
|
||||||
* @author ehlxr
|
* @author ehlxr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SFTPUtil {
|
public class SFTPUtil {
|
||||||
private static Log log = LogFactory.getLog(SFTPUtil.class);
|
private static final Log log = LogFactory.getLog(SFTPUtil.class);
|
||||||
private static String ip;
|
private static String ip;
|
||||||
private static String user;
|
private static String user;
|
||||||
private static String psw;
|
private static String psw;
|
||||||
@@ -77,7 +71,7 @@ public class SFTPUtil {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建sftp通信通道
|
// 创建sftp通信通道
|
||||||
channel = (Channel) session.openChannel("sftp");
|
channel = session.openChannel("sftp");
|
||||||
channel.connect(1000);
|
channel.connect(1000);
|
||||||
sftp = (ChannelSftp) channel;
|
sftp = (ChannelSftp) channel;
|
||||||
log.info("连接服务器[" + ip + "]成功.....");
|
log.info("连接服务器[" + ip + "]成功.....");
|
||||||
@@ -101,12 +95,9 @@ public class SFTPUtil {
|
|||||||
/**
|
/**
|
||||||
* SFTP上传文件
|
* SFTP上传文件
|
||||||
*
|
*
|
||||||
* @param desPath
|
* @param desPath ftp服务器目录
|
||||||
* ftp服务器目录
|
* @param desFileName 上传后的文件名
|
||||||
* @param desFileName
|
* @param resFile 要上传的文件
|
||||||
* 上传后的文件名
|
|
||||||
* @param resFile
|
|
||||||
* 要上传的文件
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void putFile(String desPath, String desFileName, File resFile) {
|
public static void putFile(String desPath, String desFileName, File resFile) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入排序
|
* 插入排序
|
||||||
*
|
* <p>
|
||||||
* 基本思想是:
|
* 基本思想是:
|
||||||
* 将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,
|
* 将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,
|
||||||
* 则交换,直到全部元素都比较过为止。
|
* 则交换,直到全部元素都比较过为止。
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class DirList {
|
|||||||
|
|
||||||
class DirFilter implements FilenameFilter {
|
class DirFilter implements FilenameFilter {
|
||||||
String afn;
|
String afn;
|
||||||
|
|
||||||
DirFilter(String afn) {
|
DirFilter(String afn) {
|
||||||
this.afn = afn;
|
this.afn = afn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package me.ehlxr.test;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class ExecBaics50Log {
|
public class ExecBaics50Log {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
StringBuffer sb = new StringBuffer("");
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
FileReader reader = new FileReader("C:\\Users\\ehlxr\\Desktop\\minisite\\20160606\\3\\2016-06-06(3、4、5).txt");
|
FileReader reader = new FileReader("C:\\Users\\ehlxr\\Desktop\\minisite\\20160606\\3\\2016-06-06(3、4、5).txt");
|
||||||
BufferedReader br = new BufferedReader(reader);
|
BufferedReader br = new BufferedReader(reader);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public interface IChargeCounter {
|
|||||||
* @param groupid
|
* @param groupid
|
||||||
* @param cost
|
* @param cost
|
||||||
*/
|
*/
|
||||||
public void chargeForThisResult(String campaignid, String groupid, BigDecimal cost);
|
void chargeForThisResult(String campaignid, String groupid, BigDecimal cost);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 投放次数控制
|
* 投放次数控制
|
||||||
@@ -19,5 +19,5 @@ public interface IChargeCounter {
|
|||||||
* @param count
|
* @param count
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public void counterControlForThisSumResult(String groupid, int count, String type);
|
void counterControlForThisSumResult(String groupid, int count, String type);
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@ package me.ehlxr.test;
|
|||||||
public class Test {
|
public class Test {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String s0 = "kvill";
|
String s0 = "kvill";
|
||||||
String s1 = new String("kvill");
|
String s1 = "kvill";
|
||||||
String s2 = new String("kvill");
|
String s2 = "kvill";
|
||||||
System.out.println(s0 == s1);
|
System.out.println(s0 == s1);
|
||||||
System.out.println("**********");
|
System.out.println("**********");
|
||||||
s1.intern();
|
s1.intern();
|
||||||
|
|||||||
@@ -2,11 +2,7 @@ package me.ehlxr.test;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class TestCode {
|
public class TestCode {
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package me.ehlxr.test;
|
|||||||
|
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ehlxr on 2016/9/12.
|
* Created by ehlxr on 2016/9/12.
|
||||||
*/
|
*/
|
||||||
@@ -9,7 +11,7 @@ public class TestDecodeHex {
|
|||||||
// 十六进制转字符串
|
// 十六进制转字符串
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
String data = "E88194E7B3BBE4BABAE6B7BBE58AA0E5A4B1E8B4A5";
|
String data = "E88194E7B3BBE4BABAE6B7BBE58AA0E5A4B1E8B4A5";
|
||||||
System.out.println(new String(Hex.decodeHex(data.toCharArray()), "utf-8"));
|
System.out.println(new String(Hex.decodeHex(data.toCharArray()), StandardCharsets.UTF_8));
|
||||||
|
|
||||||
System.out.println(Hex.encodeHexString("测试粗我".getBytes()));
|
System.out.println(Hex.encodeHexString("测试粗我".getBytes()));
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
package me.ehlxr.test;
|
package me.ehlxr.test;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.ResultSetMetaData;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import me.ehlxr.redis.JedisUtil;
|
import me.ehlxr.redis.JedisUtil;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class TestJdbc {
|
public class TestJdbc {
|
||||||
private static Connection getConn() {
|
private static Connection getConn() {
|
||||||
String driver = "com.mysql.jdbc.Driver";
|
String driver = "com.mysql.jdbc.Driver";
|
||||||
@@ -25,7 +16,7 @@ public class TestJdbc {
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
Class.forName(driver); // classLoader,加载对应驱动
|
Class.forName(driver); // classLoader,加载对应驱动
|
||||||
conn = (Connection) DriverManager.getConnection(url, username, password);
|
conn = DriverManager.getConnection(url, username, password);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -41,7 +32,7 @@ public class TestJdbc {
|
|||||||
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
ResultSetMetaData metaData = rs.getMetaData();
|
ResultSetMetaData metaData = rs.getMetaData();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -120,7 +111,7 @@ public class TestJdbc {
|
|||||||
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
// = 'd092c630-abfd-45a1-92f3-d0530c1caee8' LIMIT 1,3;";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
ResultSetMetaData metaData = rs.getMetaData();
|
ResultSetMetaData metaData = rs.getMetaData();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -142,7 +133,7 @@ public class TestJdbc {
|
|||||||
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
|
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class TestJdbc143 {
|
public class TestJdbc143 {
|
||||||
private static Connection getConn() {
|
private static Connection getConn() {
|
||||||
@@ -16,7 +15,7 @@ public class TestJdbc143 {
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
Class.forName(driver); // classLoader,加载对应驱动
|
Class.forName(driver); // classLoader,加载对应驱动
|
||||||
conn = (Connection) DriverManager.getConnection(url, username, password);
|
conn = DriverManager.getConnection(url, username, password);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -39,7 +38,7 @@ public class TestJdbc143 {
|
|||||||
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
|
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
|
|
||||||
if (i % 200 == 0) {
|
if (i % 200 == 0) {
|
||||||
@@ -59,7 +58,7 @@ public class TestJdbc143 {
|
|||||||
String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
|
String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class TestJdbc26 {
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
try {
|
try {
|
||||||
Class.forName(driver); // classLoader,加载对应驱动
|
Class.forName(driver); // classLoader,加载对应驱动
|
||||||
conn = (Connection) DriverManager.getConnection(url, username, password);
|
conn = DriverManager.getConnection(url, username, password);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -38,7 +38,7 @@ public class TestJdbc26 {
|
|||||||
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
|
String sql = "INSERT INTO `dsp_t_statis_by_day` (`time`, `creativeid`, `category`, `imprs`, `clks`, `cost`, `downloads`, `regists`, `flag`, `createtime`) VALUES ('2014-12-06 00:00:00', '" + cid + "', '2', '961', '9', '201860.7000', '0', '0', '0', '2015-09-14 15:07:42');";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
if (i % 200 == 0) {
|
if (i % 200 == 0) {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
@@ -57,7 +57,7 @@ public class TestJdbc26 {
|
|||||||
String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
|
String sql = "UPDATE `dsp_t_statis_by_day` SET `clks`='" + i + "' WHERE `creativeid`='068860ba-2df2-42cb-bf66-f0515c5a83aa'";
|
||||||
PreparedStatement pstmt;
|
PreparedStatement pstmt;
|
||||||
try {
|
try {
|
||||||
pstmt = (PreparedStatement) conn.prepareStatement(sql);
|
pstmt = conn.prepareStatement(sql);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -80,10 +80,8 @@ public class TestReadFile {
|
|||||||
/**
|
/**
|
||||||
* * 二分查找算法 * *
|
* * 二分查找算法 * *
|
||||||
*
|
*
|
||||||
* @param srcArray
|
* @param srcArray 有序数组 *
|
||||||
* 有序数组 *
|
* @param des 查找元素 *
|
||||||
* @param des
|
|
||||||
* 查找元素 *
|
|
||||||
* @return des的数组下标,没找到返回-1
|
* @return des的数组下标,没找到返回-1
|
||||||
*/
|
*/
|
||||||
public static long binarySearch(Long[] srcArray, long des) {
|
public static long binarySearch(Long[] srcArray, long des) {
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package me.ehlxr.test;
|
package me.ehlxr.test;
|
||||||
|
|
||||||
|
import com.caucho.hessian.client.HessianProxyFactory;
|
||||||
|
import me.ehlxr.readlogs.IReadLogs;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.caucho.hessian.client.HessianProxyFactory;
|
|
||||||
|
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import net.sf.json.JSONObject;
|
|
||||||
import me.ehlxr.readlogs.IReadLogs;
|
|
||||||
|
|
||||||
public class TestSyncLogData {
|
public class TestSyncLogData {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package me.ehlxr.test;
|
package me.ehlxr.test;
|
||||||
|
|
||||||
|
import me.ehlxr.utils.HttpClientUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.ehlxr.utils.HttpClientUtil;
|
|
||||||
|
|
||||||
public class TestThread implements Runnable {
|
public class TestThread implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
package me.ehlxr.test;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.zip.CRC32;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IntelliJ IDEA 14.0.1 注册机
|
|
||||||
*
|
|
||||||
* @author ehlxr
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class keygen {
|
|
||||||
/**
|
|
||||||
* @param s
|
|
||||||
* @param i
|
|
||||||
* @param bytes
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static short getCRC(String s, int i, byte bytes[]) {
|
|
||||||
CRC32 crc32 = new CRC32();
|
|
||||||
if (s != null) {
|
|
||||||
for (int j = 0; j < s.length(); j++) {
|
|
||||||
char c = s.charAt(j);
|
|
||||||
crc32.update(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
crc32.update(i);
|
|
||||||
crc32.update(i >> 8);
|
|
||||||
crc32.update(i >> 16);
|
|
||||||
crc32.update(i >> 24);
|
|
||||||
for (int k = 0; k < bytes.length - 2; k++) {
|
|
||||||
byte byte0 = bytes[k];
|
|
||||||
crc32.update(byte0);
|
|
||||||
}
|
|
||||||
return (short) (int) crc32.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param biginteger
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public static String encodeGroups(BigInteger biginteger) {
|
|
||||||
BigInteger beginner1 = BigInteger.valueOf(0x39aa400L);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++) {
|
|
||||||
int j = biginteger.mod(beginner1).intValue();
|
|
||||||
String s1 = encodeGroup(j);
|
|
||||||
if (i > 0) {
|
|
||||||
sb.append("-");
|
|
||||||
}
|
|
||||||
sb.append(s1);
|
|
||||||
biginteger = biginteger.divide(beginner1);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String encodeGroup(int i) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int j = 0; j < 5; j++) {
|
|
||||||
int k = i % 36;
|
|
||||||
char c;
|
|
||||||
if (k < 10) {
|
|
||||||
c = (char) (48 + k);
|
|
||||||
} else {
|
|
||||||
c = (char) ((65 + k) - 10);
|
|
||||||
}
|
|
||||||
sb.append(c);
|
|
||||||
i /= 36;
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @param days
|
|
||||||
* @param id
|
|
||||||
* @param prtype
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String MakeKey(String name, int days, int id) {
|
|
||||||
id %= 100000;
|
|
||||||
byte bkey[] = new byte[12];
|
|
||||||
bkey[0] = (byte) 1; // Product type: IntelliJ IDEA is 1
|
|
||||||
bkey[1] = 14; // version
|
|
||||||
Date d = new Date();
|
|
||||||
long ld = (d.getTime() >> 16);
|
|
||||||
bkey[2] = (byte) (ld & 255);
|
|
||||||
bkey[3] = (byte) ((ld >> 8) & 255);
|
|
||||||
bkey[4] = (byte) ((ld >> 16) & 255);
|
|
||||||
bkey[5] = (byte) ((ld >> 24) & 255);
|
|
||||||
days &= 0xffff;
|
|
||||||
bkey[6] = (byte) (days & 255);
|
|
||||||
bkey[7] = (byte) ((days >> 8) & 255);
|
|
||||||
bkey[8] = 105;
|
|
||||||
bkey[9] = -59;
|
|
||||||
bkey[10] = 0;
|
|
||||||
bkey[11] = 0;
|
|
||||||
int w = getCRC(name, id % 100000, bkey);
|
|
||||||
bkey[10] = (byte) (w & 255);
|
|
||||||
bkey[11] = (byte) ((w >> 8) & 255);
|
|
||||||
BigInteger pow = new BigInteger("89126272330128007543578052027888001981", 10);
|
|
||||||
BigInteger mod = new BigInteger("86f71688cdd2612ca117d1f54bdae029", 16);
|
|
||||||
BigInteger k0 = new BigInteger(bkey);
|
|
||||||
BigInteger k1 = k0.modPow(pow, mod);
|
|
||||||
String s0 = Integer.toString(id);
|
|
||||||
String sz = "0";
|
|
||||||
while (s0.length() != 5) {
|
|
||||||
s0 = sz.concat(s0);
|
|
||||||
}
|
|
||||||
s0 = s0.concat("-");
|
|
||||||
String s1 = encodeGroups(k1);
|
|
||||||
s0 = s0.concat(s1);
|
|
||||||
return s0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Random r = new Random();
|
|
||||||
String userid = "elvin";
|
|
||||||
System.out.println(userid+":"+MakeKey(userid, 0, r.nextInt(100000)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,20 +9,16 @@ import org.bouncycastle.crypto.params.ParametersWithIV;
|
|||||||
import org.bouncycastle.util.encoders.Hex;
|
import org.bouncycastle.util.encoders.Hex;
|
||||||
/**
|
/**
|
||||||
* AES encryption and decryption tool.
|
* AES encryption and decryption tool.
|
||||||
*
|
|
||||||
* @author ben
|
|
||||||
* @creation 2014年3月20日
|
|
||||||
*/
|
*/
|
||||||
public class AESTool {
|
public class AESTool {
|
||||||
private static byte[] initVector = { 0x32, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31,
|
private static final byte[] initVector = {0x32, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31,
|
||||||
0x38, 0x27, 0x36, 0x35, 0x33, 0x23, 0x32, 0x31};
|
0x38, 0x27, 0x36, 0x35, 0x33, 0x23, 0x32, 0x31};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt the content with a given key using aes algorithm.
|
* Encrypt the content with a given key using aes algorithm.
|
||||||
*
|
*
|
||||||
* @param content
|
* @param content
|
||||||
* @param key
|
* @param key must contain exactly 32 characters
|
||||||
* must contain exactly 32 characters
|
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ import java.util.Arrays;
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @version 2.2
|
|
||||||
* @author Mikael Grev Date: 2004-aug-02 Time: 11:31:11
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Base64 {
|
public class Base64 {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package me.ehlxr.utils;
|
package me.ehlxr.utils;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ehlxr on 2017/3/15.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ehlxr on 2017/3/15.
|
||||||
|
*/
|
||||||
public class MyUrlDemo {
|
public class MyUrlDemo {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
###author liuling
|
|
||||||
###token生成和校验相关配置
|
###token生成和校验相关配置
|
||||||
[tokenVersion<1>]
|
[tokenVersion<1>]=
|
||||||
###生成token时的密钥
|
###生成token时的密钥
|
||||||
create_token_key=QJ=*S:y^s0$!@#&*()%xZ~&U8($*_+r?
|
create_token_key=QJ=*S:y^s0$!@#&*()%xZ~&U8($*_+r?
|
||||||
###自校验时的密钥
|
###自校验时的密钥
|
||||||
check_token_key=QJs#!@%er!#E#$%^%@@!@=**I()^%?
|
check_token_key=QJs#!@%er!#E#$%^%@@!@=**I()^%?
|
||||||
###取MD5加密后的哪几位做为自校验位,共计4字节,32位。最大数字不能超过16
|
###取MD5加密后的哪几位做为自校验位,共计4字节,32位。最大数字不能超过16
|
||||||
check=1,4,6,7
|
check=1,4,6,7
|
||||||
|
[tokenVersion<2>]=
|
||||||
|
|
||||||
[tokenVersion<2>]
|
|
||||||
###生成token时的密钥
|
###生成token时的密钥
|
||||||
create_token_key=D#$%^@W#Rj8)@9o%&rgyYL_+!Ldcr5td
|
create_token_key=D#$%^@W#Rj8)@9o%&rgyYL_+!Ldcr5td
|
||||||
###自校验时的密钥
|
###自校验时的密钥
|
||||||
|
|||||||
Reference in New Issue
Block a user