main
parent
8041bd7079
commit
d233bf28b3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,462 @@
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
public class AnprImageJob implements Job {
|
||||
|
||||
private String jobSays;
|
||||
private float myFloatValue;
|
||||
private ArrayList<Date> state;
|
||||
|
||||
private String[] g_strDB = new String[4];
|
||||
private String[] g_strFTP = new String[6];
|
||||
private String[] g_strFTPColl = new String[4];
|
||||
|
||||
private String g_strTenel = "";
|
||||
private List<String> g_listN1 = new ArrayList<String>();
|
||||
private List<String> g_listN3 = new ArrayList<String>();
|
||||
|
||||
public AnprImageJob() {
|
||||
try {
|
||||
// 프로퍼티 파일 위치
|
||||
String propFile = "./config.properties";
|
||||
|
||||
// 프로퍼티 객체 생성
|
||||
Properties props = new Properties();
|
||||
|
||||
// 프로퍼티 파일 스트림에 담기
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
|
||||
// 프로퍼티 파일 로딩
|
||||
props.load(new java.io.BufferedInputStream(fis));
|
||||
|
||||
// 항목 읽기
|
||||
g_strDB[0] = props.getProperty("db_driver");
|
||||
g_strDB[1] = props.getProperty("db_connect");
|
||||
g_strDB[2] = props.getProperty("db_id");
|
||||
g_strDB[3] = props.getProperty("db_pw");
|
||||
|
||||
// 항목 읽기
|
||||
g_strFTP[0] = props.getProperty("path_org");
|
||||
g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
g_strFTP[2] = props.getProperty("ftp_id");
|
||||
g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
g_strFTP[4] = props.getProperty("api_url");
|
||||
g_strFTP[5] = props.getProperty("path_desc");
|
||||
|
||||
g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
g_strFTPColl[3] = props.getProperty("center_ftp_ip");
|
||||
|
||||
g_strTenel = props.getProperty("tennel_no");
|
||||
|
||||
props.clear();
|
||||
props = null;
|
||||
|
||||
|
||||
this.g_listN1.add("01");
|
||||
this.g_listN1.add("02");
|
||||
this.g_listN1.add("03");
|
||||
this.g_listN1.add("04");
|
||||
this.g_listN1.add("05");
|
||||
this.g_listN1.add("06");
|
||||
this.g_listN1.add("07");
|
||||
this.g_listN1.add("08");
|
||||
|
||||
this.g_listN3.add("01");
|
||||
this.g_listN3.add("02");
|
||||
this.g_listN3.add("03");
|
||||
this.g_listN3.add("04");
|
||||
this.g_listN3.add("05");
|
||||
this.g_listN3.add("06");
|
||||
this.g_listN3.add("07");
|
||||
this.g_listN3.add("08");
|
||||
this.g_listN3.add("09");
|
||||
this.g_listN3.add("10");
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void findFileList(String source, List<String> list) {
|
||||
File dir = new File(source);
|
||||
File[] fileList = dir.listFiles();
|
||||
try {
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
File file = fileList[i];
|
||||
System.out.println("=== = " + file.getName());
|
||||
if (file.isFile()) {
|
||||
String tempFileName = file.getName();
|
||||
if (tempFileName.toLowerCase().endsWith("jpg") == true)
|
||||
list.add(tempFileName);
|
||||
|
||||
// 파일이 있다면 파일 이름 출력
|
||||
// System.out.println("\t 파일 이름 = " + file.getName());
|
||||
} else if (file.isDirectory()) {
|
||||
if (file.getName().equals("send") == true)
|
||||
continue;
|
||||
// System.out.println("디렉토리 이름 = " + file.getName());
|
||||
|
||||
// 서브디렉토리가 존재하면 재귀적 방법으로 다시 탐색
|
||||
findFileList(file.getCanonicalPath().toString(), list);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String transFileName(String strOrgFile, JSONObject jsonParam, Map<String, String> mapDefault) {
|
||||
//
|
||||
Map<String, String> cctvID = new HashMap<String, String>();
|
||||
|
||||
cctvID.put("101", "A10401001");
|
||||
cctvID.put("102", "A10301002");
|
||||
cctvID.put("103", "A10201003");
|
||||
cctvID.put("104", "A10101004");
|
||||
cctvID.put("105", "A10111005");
|
||||
cctvID.put("106", "A10211006");
|
||||
cctvID.put("107", "A10311007");
|
||||
cctvID.put("108", "A10411008");
|
||||
cctvID.put("301", "A10503001");
|
||||
cctvID.put("302", "A10403002");
|
||||
cctvID.put("303", "A10303003");
|
||||
cctvID.put("304", "A10203004");
|
||||
cctvID.put("305", "폐쇄차로");
|
||||
cctvID.put("306", "폐쇄차로");
|
||||
cctvID.put("307", "A10213005");
|
||||
cctvID.put("308", "A10313006");
|
||||
cctvID.put("309", "A10413007");
|
||||
cctvID.put("310", "A10513008");
|
||||
|
||||
String[] strarr = strOrgFile.split("_");
|
||||
|
||||
String tennel = strarr[3].substring(0, 1);
|
||||
String line = strarr[3].substring(1, 3);
|
||||
String dirc = strarr[3].substring(3);
|
||||
|
||||
// 미납 이미지 전송 경로
|
||||
mapDefault.put("image_path_desc", String.format("/data2/DOTR/%s/0%s/IMAGE/", strarr[0], tennel));
|
||||
mapDefault.put("image_path_desc_center", String.format("/DOTR/%s/0%s/IMAGE/", strarr[0], tennel));
|
||||
mapDefault.put("work_times", strarr[1]);
|
||||
mapDefault.put("seqno", strarr[2]);
|
||||
|
||||
int n = Integer.parseInt(strarr[2].substring(6, 8));
|
||||
|
||||
if (n >= 40 && n < 50)
|
||||
mapDefault.put("collect_id", "40");
|
||||
else if (n >= 60 && n < 70)
|
||||
mapDefault.put("collect_id", "40");
|
||||
else
|
||||
mapDefault.put("collect_id", String.format("%02d", n));
|
||||
|
||||
jsonParam.put("camId", cctvID.get(tennel + line));
|
||||
jsonParam.put("pasageTime", strarr[0] + strarr[1].substring(0, 6));
|
||||
jsonParam.put("vhcleNum", MakeCarNoHex2CarNo.makeCarNoHex2CarNo(strarr[4].trim()));
|
||||
jsonParam.put("vhcleKnd", strarr[5].substring(0, 1));
|
||||
jsonParam.put("vhcleColor", "0");
|
||||
jsonParam.put("allImagePath", "./car_img/"); // 아래에서 설정....
|
||||
jsonParam.put("vhcleImagePath", "");
|
||||
jsonParam.put("nopltImagePath", "");
|
||||
jsonParam.put("inputKnd", "");
|
||||
jsonParam.put("vhcleDrc", dirc);
|
||||
jsonParam.put("recogCnfdncRate", "95");
|
||||
jsonParam.put("tfclneInfo", line);
|
||||
jsonParam.put("recogReqreTime", "000000");
|
||||
jsonParam.put("regltTrgetSe", "20");
|
||||
|
||||
StringBuilder pathOrg = new StringBuilder();
|
||||
pathOrg.append(g_strFTP[0]);
|
||||
/*
|
||||
* pathOrg.append(strarr[0].substring(4, 6)); // day
|
||||
* pathOrg.append("/"); pathOrg.append(line); // line
|
||||
* pathOrg.append("/");
|
||||
*/
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(g_strFTP[5]);
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(0, 4));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(4, 6));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(6, 8));
|
||||
path.append("/");
|
||||
path.append(cctvID.get(tennel + line));
|
||||
path.append("/");
|
||||
path.append(strarr[1].substring(0, 2));
|
||||
path.append("/");
|
||||
|
||||
StringBuilder strbuf = new StringBuilder();
|
||||
strbuf.append("2");
|
||||
if (tennel.equals("1"))
|
||||
strbuf.append("NO");
|
||||
else if (tennel.equals("3"))
|
||||
strbuf.append("NT");
|
||||
else
|
||||
return null;
|
||||
|
||||
strbuf.append("TT");
|
||||
strbuf.append("C");
|
||||
strbuf.append("2");
|
||||
strbuf.append("_");
|
||||
|
||||
strbuf.append(cctvID.get(tennel + line));
|
||||
strbuf.append("_");
|
||||
|
||||
strbuf.append(strarr[0]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[1]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[2]);
|
||||
strbuf.append(".jpg");
|
||||
|
||||
mapDefault.put("image_file_new2",
|
||||
String.format("0%s%s%s%sS.JPG", tennel, line, strarr[0], strarr[1].substring(0, 6)));
|
||||
|
||||
mapDefault.put("image_path", pathOrg.toString());
|
||||
mapDefault.put("image_file", strbuf.toString());
|
||||
|
||||
|
||||
System.out.println("=== pathOrg.toString() : " + pathOrg.toString());
|
||||
System.out.println("=== path.toString() : " + path.toString());
|
||||
System.out.println("=== strbuf.toString() : " + strbuf.toString());
|
||||
|
||||
jsonParam.put("allImagePath",String.format("%s/%s",path.toString(), strbuf.toString()));
|
||||
|
||||
System.out.println("=== : " + jsonParam.toJSONString());
|
||||
return pathOrg.toString() + "#" + path.toString() + "#" + strbuf.toString();
|
||||
}
|
||||
|
||||
private void callAnprCarnoSend(String strJson) {
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
try {
|
||||
URL url = new URL(g_strFTP[4]);
|
||||
System.out.println("==== 수집서버 주소 : " + g_strFTP[4]);
|
||||
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
// 요청응답 타임아웃 설정
|
||||
connection.setConnectTimeout(30000); // 30 sec
|
||||
// 읽기 타임아웃 설정
|
||||
connection.setReadTimeout(30000);
|
||||
// connection.setAllowUserInteraction(true);
|
||||
|
||||
// Http Header Setting
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
|
||||
// Http Parameter Sending
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(strJson.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
int resCode = connection.getResponseCode();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String inputLine = null;
|
||||
|
||||
System.out.println("==== : " + resCode);
|
||||
if (resCode == HttpsURLConnection.HTTP_OK) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
|
||||
System.out.println("==== " + sb.toString());
|
||||
} else {
|
||||
if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
} else {
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("==== Http Error Resopnse : " + "");
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void runCarNoImageSend() {
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
String pathOrg = g_strFTP[0];
|
||||
findFileList(pathOrg, list);
|
||||
if (list.size() == 0) {
|
||||
System.out.println("=== 신규 이미지 없음");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> mapDefaultCar = new HashMap<String, String>();
|
||||
|
||||
boolean isOk = false;
|
||||
String strNewFile = "";
|
||||
String[] strTargPath = null;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTP[1], g_strFTP[2], g_strFTP[3]);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
mapDefaultCar.clear();
|
||||
|
||||
// 1. renametomvoe -> 2. ftp upload -> 3. api cxall
|
||||
strNewFile = transFileName(list.get(i), jsonParam, mapDefaultCar);
|
||||
if (strNewFile == null || strNewFile.equals("") == true || jsonParam.size() == 0)
|
||||
continue;
|
||||
|
||||
strTargPath = strNewFile.split("#");
|
||||
System.out.println("===" + strTargPath[0]);
|
||||
System.out.println("===" + strTargPath[1]);
|
||||
System.out.println("===" + strTargPath[2]);
|
||||
// 해당 디렉토리가 없을경우 디렉토리를 생성합니다.
|
||||
File Folder = new File(strTargPath[0] + "send/");
|
||||
if (!Folder.exists()) {
|
||||
try {
|
||||
Folder.mkdir(); // 폴더 생성합니다.
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("이미 폴더가 생성되어 있습니다.");
|
||||
}
|
||||
|
||||
// 2.
|
||||
File file = new File(strTargPath[0] + list.get(i));
|
||||
File fileNew = new File(strTargPath[0] + "send/" + strTargPath[2]);
|
||||
|
||||
if (fileNew.exists())
|
||||
fileNew.delete();
|
||||
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
|
||||
System.out.println("=== 3 : " + strTargPath[0]);
|
||||
System.out.println("=== 4 : " + strTargPath[1]);
|
||||
|
||||
isOk = false;
|
||||
|
||||
try {
|
||||
sftp.mkdir2( strTargPath[1].substring(1));
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
sftp.upload( strTargPath[1], fileNew);
|
||||
} catch (SftpException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
isOk = true;
|
||||
|
||||
|
||||
if(isOk == false)
|
||||
return;
|
||||
// 3.
|
||||
callAnprCarnoSend(jsonParam.toJSONString());
|
||||
jsonParam.clear();
|
||||
|
||||
|
||||
// 4
|
||||
|
||||
} // end for
|
||||
|
||||
sftp.disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 스케줄러에 인해 주기적으로 실행되는 함수.
|
||||
*/
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
state.add(new Date());
|
||||
|
||||
System.err.println("Instance " + key + " of DmbJob says: " + jobSays + ", and val is: " + myFloatValue
|
||||
+ ", state size:" + state.size() + "," + state.get(state.size() - 1));
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int date = cal.get(Calendar.DATE);
|
||||
System.out.println("======== 차로개수 : " + g_listN3.size());
|
||||
for(int i = 0; i < g_listN3.size(); i++) {
|
||||
g_strFTP[0] = String.format("%s/%02d/%s/", g_strFTP[0], date, g_listN3.get(i));
|
||||
System.out.println(String.format("======== %d : %s", i, g_listN3.get(i)));
|
||||
|
||||
//runCarNoImageSend();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 아래와 같이 setter 형식으로 값을 받을 수도 있고 혹은, datamap을 통해 얻을 수 있음
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,550 @@
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
import oracle.jdbc.OracleConnection;
|
||||
import oracle.jdbc.OraclePreparedStatement;
|
||||
|
||||
public class DumbJob implements Job {
|
||||
|
||||
private String jobSays;
|
||||
private float myFloatValue;
|
||||
private ArrayList<Date> state;
|
||||
|
||||
private static String[] g_strDB = new String[4];
|
||||
private static String[] g_strFTP = new String[5];
|
||||
private static String[] g_strFTPColl = new String[53];
|
||||
|
||||
public DumbJob() {
|
||||
try {
|
||||
// 프로퍼티 파일 위치
|
||||
String propFile = "./config.properties";
|
||||
|
||||
// 프로퍼티 객체 생성
|
||||
Properties props = new Properties();
|
||||
|
||||
// 프로퍼티 파일 스트림에 담기
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
|
||||
// 프로퍼티 파일 로딩
|
||||
props.load(new java.io.BufferedInputStream(fis));
|
||||
|
||||
// 항목 읽기
|
||||
g_strDB[0] = props.getProperty("db_driver");
|
||||
g_strDB[1] = props.getProperty("db_connect");
|
||||
g_strDB[2] = props.getProperty("db_id");
|
||||
g_strDB[3] = props.getProperty("db_pw");
|
||||
|
||||
// 항목 읽기
|
||||
g_strFTP[0] = props.getProperty("path_org");
|
||||
g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
g_strFTP[2] = props.getProperty("ftp_id");
|
||||
g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
g_strFTP[4] = props.getProperty("api_url");
|
||||
|
||||
g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int date = cal.get ( Calendar.DATE ) ;
|
||||
g_strFTP[0] = String.format("%s/%02d/07/", g_strFTP[0],date );
|
||||
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void findFileList(String source, List<String> list) {
|
||||
File dir = new File(source);
|
||||
File[] fileList = dir.listFiles();
|
||||
try {
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
File file = fileList[i];
|
||||
System.out.println("=== = " + file.getName());
|
||||
if (file.isFile()) {
|
||||
String tempFileName = file.getName();
|
||||
if (tempFileName.toLowerCase().endsWith("jpg") == true)
|
||||
list.add(tempFileName);
|
||||
|
||||
// 파일이 있다면 파일 이름 출력
|
||||
// System.out.println("\t 파일 이름 = " + file.getName());
|
||||
} else if (file.isDirectory()) {
|
||||
if(file.getName().equals("send") == true)
|
||||
continue;
|
||||
//System.out.println("디렉토리 이름 = " + file.getName());
|
||||
|
||||
// 서브디렉토리가 존재하면 재귀적 방법으로 다시 탐색
|
||||
findFileList(file.getCanonicalPath().toString(), list);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String transFileName(String strOrgFile, JSONObject jsonParam, Map<String, String> mapDefault) {
|
||||
//
|
||||
Map<String, String> cctvID = new HashMap<String, String>();
|
||||
|
||||
cctvID.put("101", "A20201107");
|
||||
cctvID.put("103", "A20201109");
|
||||
cctvID.put("104", "A20211110");
|
||||
cctvID.put("105", "A20201111");
|
||||
cctvID.put("106", "A20211112");
|
||||
cctvID.put("107", "A20201113");
|
||||
cctvID.put("108", "A20211114");
|
||||
cctvID.put("301", "A20203115");
|
||||
cctvID.put("302", "A20213116");
|
||||
cctvID.put("303", "A10103117");
|
||||
cctvID.put("304", "A10103118");
|
||||
// cctvID.put("305", "폐쇄차로");
|
||||
// cctvID.put("306", "폐쇄차로");
|
||||
cctvID.put("307", "A1013119");
|
||||
cctvID.put("308", "A10103120");
|
||||
cctvID.put("309", "A10103121");
|
||||
cctvID.put("310", "A10103122");
|
||||
|
||||
String[] strarr = strOrgFile.split("_");
|
||||
|
||||
String tennel = strarr[3].substring(0, 1);
|
||||
String line = strarr[3].substring(1, 3);
|
||||
String dirc = strarr[3].substring(3);
|
||||
|
||||
// 미납 이미지 전송 경로
|
||||
mapDefault.put("image_path_desc", String.format("/data2/DOTR/%s/0%s/IMAGE/", strarr[0], tennel));
|
||||
mapDefault.put("work_times", strarr[1]);
|
||||
mapDefault.put("seqno", strarr[2]);
|
||||
|
||||
int n = Integer .parseInt(strarr[2].substring(6, 8));
|
||||
|
||||
if(n >=40 && n< 50)
|
||||
mapDefault.put("collect_id", "40");
|
||||
else if(n >=60 && n< 70)
|
||||
mapDefault.put("collect_id", "40");
|
||||
else
|
||||
mapDefault.put("collect_id", String.format("%02d", n));
|
||||
|
||||
|
||||
jsonParam.put("camId", cctvID.get(tennel + line));
|
||||
jsonParam.put("pasageTime", strarr[0] + strarr[1]);
|
||||
jsonParam.put("vhcleNum", MakeCarNoHex2CarNo.makeCarNoHex2CarNo(strarr[4].trim()));
|
||||
jsonParam.put("vhcleKnd", strarr[5].substring(1, 2));
|
||||
jsonParam.put("vhcleColor", "0");
|
||||
jsonParam.put("allImagePath", "./car_img/"); // ???
|
||||
jsonParam.put("vhcleImagePath", "");
|
||||
jsonParam.put("nopltImagePath", "");
|
||||
jsonParam.put("inputKnd", "");
|
||||
jsonParam.put("vhcleDrc", dirc);
|
||||
jsonParam.put("recogCnfdncRate", "00");
|
||||
jsonParam.put("tfclneInfo", line);
|
||||
jsonParam.put("recogReqreTime", "000000");
|
||||
jsonParam.put("regltTrgetSe", "20");
|
||||
|
||||
System.out.println("=== : " + jsonParam.toJSONString());
|
||||
|
||||
StringBuilder pathOrg = new StringBuilder();
|
||||
pathOrg.append(g_strFTP[0]);
|
||||
/* pathOrg.append(strarr[0].substring(4, 6)); // day
|
||||
pathOrg.append("/");
|
||||
pathOrg.append(line); // line
|
||||
pathOrg.append("/");*/
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(0, 4));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(4, 6));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(6, 8));
|
||||
path.append("/");
|
||||
path.append(cctvID.get(tennel + line));
|
||||
path.append("/");
|
||||
path.append(strarr[1].substring(0, 2));
|
||||
path.append("/");
|
||||
|
||||
StringBuilder strbuf = new StringBuilder();
|
||||
strbuf.append("2");
|
||||
if (tennel.equals("1"))
|
||||
strbuf.append("NO");
|
||||
else if (tennel.equals("3"))
|
||||
strbuf.append("NT");
|
||||
else
|
||||
return null;
|
||||
|
||||
strbuf.append("TT");
|
||||
strbuf.append("C");
|
||||
strbuf.append("2");
|
||||
strbuf.append("_");
|
||||
|
||||
strbuf.append(cctvID.get(tennel + line));
|
||||
strbuf.append("_");
|
||||
|
||||
strbuf.append(strarr[0]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[1]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[2]);
|
||||
strbuf.append(".jpg");
|
||||
|
||||
mapDefault.put("image_file_new2", String.format("%s%s%s%sS.JPG", tennel, line, strarr[0], strarr[1].substring(0, 6)));
|
||||
|
||||
mapDefault.put("image_path", pathOrg.toString());
|
||||
mapDefault.put("image_file", strbuf.toString());
|
||||
|
||||
return pathOrg.toString() + "#" + path.toString() + "#" + strbuf.toString();
|
||||
}
|
||||
|
||||
private void callAnprCarnoSend(String strJson) {
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
try {
|
||||
URL url = new URL(g_strFTP[4]);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
// 요청응답 타임아웃 설정
|
||||
connection.setConnectTimeout(30000); // 30 sec
|
||||
// 읽기 타임아웃 설정
|
||||
connection.setReadTimeout(30000);
|
||||
// connection.setAllowUserInteraction(true);
|
||||
|
||||
// Http Header Setting
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
|
||||
// Http Parameter Sending
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(strJson.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
int resCode = connection.getResponseCode();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String inputLine = null;
|
||||
|
||||
System.out.println("==== : " + resCode);
|
||||
if (resCode == HttpsURLConnection.HTTP_OK) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
|
||||
System.out.println("==== " + sb.toString());
|
||||
} else {
|
||||
if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
} else {
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("==== Http Error Resopnse : " + "");
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@SuppressWarnings("unused")
|
||||
private void sendImage(String path, String filename) {
|
||||
String pathOrg = g_strFTP[0];
|
||||
|
||||
String strPeneltyPah = "";
|
||||
String strRemotPah = "";
|
||||
String strNewFile = "";
|
||||
String[] strTargPath = null;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTP[1], g_strFTP[2], g_strFTP[3]);
|
||||
|
||||
// 1. renametomvoe -> 2. ftp upload -> 3. api 콜
|
||||
strNewFile = transFileName(filename, jsonParam, strPeneltyPah);
|
||||
if (strNewFile == null || strNewFile.equals("") == true || jsonParam.size() == 0)
|
||||
return;
|
||||
;
|
||||
|
||||
strTargPath = strNewFile.split("#");
|
||||
|
||||
// 2.
|
||||
File file = new File(path + filename);
|
||||
File fileNew = new File(pathOrg + "send/" + strTargPath[1]);
|
||||
// fileNew.delete();
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
|
||||
System.out.println("=== " + strTargPath[0]);
|
||||
System.out.println("=== " + strTargPath[1]);
|
||||
try {
|
||||
strRemotPah = sftp.mkdir(strTargPath[0]);
|
||||
|
||||
try {
|
||||
sftp.upload(strRemotPah, fileNew);
|
||||
sftp.disconnect();
|
||||
// 3.
|
||||
// callAnprCarnoSend(jsonParam.toJSONString());
|
||||
jsonParam.clear();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (SftpException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// 스케줄러에 인해 주기적으로 실행되는 함수.
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
state.add(new Date());
|
||||
|
||||
System.err.println("Instance " + key + " of DmbJob says: " + jobSays + ", and val is: " + myFloatValue
|
||||
+ ", state size:" + state.size() + "," + state.get(state.size() - 1));
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
String pathOrg = g_strFTP[0];
|
||||
findFileList(pathOrg, list);
|
||||
if (list.size() == 0) {
|
||||
System.out.println("=== 신규 이미지 없음");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> mapDefaultCar = new HashMap<String, String>();
|
||||
|
||||
String strRemotPah = "";
|
||||
String strNewFile = "";
|
||||
String[] strTargPath = null;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTP[1], g_strFTP[2], g_strFTP[3]);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
mapDefaultCar.clear();
|
||||
|
||||
// 1. renametomvoe -> 2. ftp upload -> 3. api 콜 -> 미납이면 이미지 전송 및 DB
|
||||
// 업데이트
|
||||
strNewFile = transFileName(list.get(i), jsonParam, mapDefaultCar);
|
||||
if (strNewFile == null || strNewFile.equals("") == true || jsonParam.size() == 0)
|
||||
continue;
|
||||
|
||||
strTargPath = strNewFile.split("#");
|
||||
|
||||
// 해당 디렉토리가 없을경우 디렉토리를 생성합니다.
|
||||
File Folder = new File(strTargPath[0] + "send/");
|
||||
if (!Folder.exists()) {
|
||||
try {
|
||||
Folder.mkdir(); // 폴더 생성합니다.
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("이미 폴더가 생성되어 있습니다.");
|
||||
}
|
||||
|
||||
// 2.
|
||||
File file = new File(strTargPath[0] + list.get(i));
|
||||
File fileNew = new File(strTargPath[0] + "send/" + strTargPath[2]);
|
||||
|
||||
if (fileNew.exists())
|
||||
fileNew.delete();
|
||||
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
|
||||
System.out.println("=== " + strTargPath[0]);
|
||||
System.out.println("=== " + strTargPath[1]);
|
||||
|
||||
try {
|
||||
//strRemotPah = sftp.mkdir(strTargPath[0]);
|
||||
|
||||
// 3.
|
||||
callAnprCarnoSend(jsonParam.toJSONString());
|
||||
jsonParam.clear();
|
||||
/*
|
||||
// 4. 미납처리...
|
||||
if (mapDefaultCar.get("collect_id").equals("40") == true) {
|
||||
DefaultCar(mapDefaultCar);
|
||||
}*/
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
sftp.disconnect();
|
||||
}
|
||||
|
||||
private void DefaultCar(Map<String, String>map) throws SQLException {
|
||||
|
||||
boolean isOk = false;
|
||||
|
||||
// 1. 이미지 전송
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTPColl[0], g_strFTPColl[1], g_strFTPColl[2]);
|
||||
String str = map.get("image_path") + "send/";
|
||||
System.out.println("=== : "+ str);
|
||||
try {
|
||||
|
||||
File file = new File(str + map.get("image_file"));
|
||||
File fileNew = new File(str + map.get("image_file_new2"));
|
||||
try {
|
||||
sftp.mkdir2(map.get("image_path_desc").substring(1));
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
|
||||
if (fileNew.exists())
|
||||
fileNew.delete();
|
||||
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
|
||||
|
||||
sftp.upload(map.get("image_path_desc"), fileNew);
|
||||
|
||||
isOk = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SftpException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(isOk == false)
|
||||
return;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
//현재 년도, 월, 일
|
||||
int year = cal.get ( Calendar.YEAR );
|
||||
int month = cal.get ( Calendar.MONTH ) + 1 ;
|
||||
int day = cal.get ( Calendar.DATE ) ;
|
||||
|
||||
|
||||
// DB update
|
||||
OracleConnection conn = null; // 통상 Connection으로 선언
|
||||
OraclePreparedStatement ps = null; // 통상 PreparedStatement로 선언
|
||||
|
||||
try {
|
||||
conn = (OracleConnection) getOrclConn();
|
||||
|
||||
String sql = "update FARE_TERMINAL_INFO";
|
||||
sql = sql + " set CARS_STOP_PICTURE_FILE = ? ";
|
||||
sql = sql + " where year = ? and month = ? and day = ?";
|
||||
sql = sql + " and WORK_TIMES = ? and SEQNO = ?";
|
||||
sql = sql + " and fare_office_id = '03' and booth_id = '07'";
|
||||
|
||||
ps = (OraclePreparedStatement) conn.prepareStatement(sql);
|
||||
System.out.println(String.format("=== %s, %s, %s", map.get("image_file_new2"), map.get("work_times"),map.get("seqno")) );
|
||||
ps.setString(1, map.get("image_file"));
|
||||
|
||||
ps.setString(2,String.format("%04d", year));
|
||||
ps.setString(3,String.format("%02d", month));
|
||||
ps.setString(4,String.format("%02d", day));
|
||||
|
||||
ps.setString(5, map.get("work_times").substring(0, 6));
|
||||
ps.setInt(6, Integer.parseInt(map.get("seqno")));
|
||||
ps.executeUpdate();
|
||||
|
||||
ps.close();
|
||||
|
||||
sql = "update default_fare_read_info";
|
||||
sql = sql + " set CARS_STOP_PICTURE_FILE = ? ";
|
||||
sql = sql + " where year = ? and month = ? and day = ?";
|
||||
sql = sql + " and WORK_TIMES = ? and SEQNO = ?";
|
||||
sql = sql + " and fare_office_id = '03' and booth_id = '07'";
|
||||
|
||||
ps = (OraclePreparedStatement) conn.prepareStatement(sql);
|
||||
System.out.println(String.format("=== %s, %s, %s", map.get("image_file_new2"), map.get("work_times"),map.get("seqno")) );
|
||||
ps.setString(1, map.get("image_file"));
|
||||
|
||||
ps.setString(2,String.format("%04d", year));
|
||||
ps.setString(3,String.format("%02d", month));
|
||||
ps.setString(4,String.format("%02d", day));
|
||||
|
||||
ps.setString(5, map.get("work_times").substring(0, 6));
|
||||
ps.setInt(6, Integer.parseInt(map.get("seqno")));
|
||||
ps.executeUpdate();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
ps.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
private Connection getOrclConn() throws Exception {
|
||||
Class.forName(g_strDB[0]);
|
||||
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
||||
}
|
||||
|
||||
// 아래와 같이 setter 형식으로 값을 받을 수도 있고 혹은, datamap을 통해 얻을 수 있음
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,446 @@
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
import oracle.jdbc.OracleConnection;
|
||||
import oracle.jdbc.OraclePreparedStatement;
|
||||
|
||||
public class DumbJob implements Job {
|
||||
|
||||
private String jobSays;
|
||||
private float myFloatValue;
|
||||
private ArrayList<Date> state;
|
||||
|
||||
private static String[] g_strDB = new String[4];
|
||||
private static String[] g_strFTP = new String[5];
|
||||
private static String[] g_strFTPColl = new String[4];
|
||||
|
||||
public DumbJob() {
|
||||
try {
|
||||
// 프로퍼티 파일 위치
|
||||
String propFile = "./config.properties";
|
||||
|
||||
// 프로퍼티 객체 생성
|
||||
Properties props = new Properties();
|
||||
|
||||
// 프로퍼티 파일 스트림에 담기
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
|
||||
// 프로퍼티 파일 로딩
|
||||
props.load(new java.io.BufferedInputStream(fis));
|
||||
|
||||
// 항목 읽기
|
||||
g_strDB[0] = props.getProperty("db_driver");
|
||||
g_strDB[1] = props.getProperty("db_connect");
|
||||
g_strDB[2] = props.getProperty("db_id");
|
||||
g_strDB[3] = props.getProperty("db_pw");
|
||||
|
||||
// 항목 읽기
|
||||
g_strFTP[0] = props.getProperty("path_org");
|
||||
g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
g_strFTP[2] = props.getProperty("ftp_id");
|
||||
g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
g_strFTP[4] = props.getProperty("api_url");
|
||||
|
||||
g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
g_strFTPColl[3] = props.getProperty("center_ftp_ip");
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int date = cal.get ( Calendar.DATE ) ;
|
||||
g_strFTP[0] = String.format("%s/%02d/07/", g_strFTP[0],date );
|
||||
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void findFileList(String source, List<String> list) {
|
||||
File dir = new File(source);
|
||||
File[] fileList = dir.listFiles();
|
||||
try {
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
File file = fileList[i];
|
||||
System.out.println("=== = " + file.getName());
|
||||
if (file.isFile()) {
|
||||
String tempFileName = file.getName();
|
||||
if (tempFileName.toLowerCase().endsWith("jpg") == true)
|
||||
list.add(tempFileName);
|
||||
|
||||
// 파일이 있다면 파일 이름 출력
|
||||
// System.out.println("\t 파일 이름 = " + file.getName());
|
||||
} else if (file.isDirectory()) {
|
||||
if(file.getName().equals("send") == true)
|
||||
continue;
|
||||
//System.out.println("디렉토리 이름 = " + file.getName());
|
||||
|
||||
// 서브디렉토리가 존재하면 재귀적 방법으로 다시 탐색
|
||||
findFileList(file.getCanonicalPath().toString(), list);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String transFileName(String strOrgFile, JSONObject jsonParam, Map<String, String> mapDefault) {
|
||||
//
|
||||
Map<String, String> cctvID = new HashMap<String, String>();
|
||||
|
||||
cctvID.put("101", "A20201107");
|
||||
cctvID.put("102", "A20201108");
|
||||
cctvID.put("103", "A20201109");
|
||||
cctvID.put("104", "A20211110");
|
||||
cctvID.put("105", "A20201111");
|
||||
cctvID.put("106", "A20211112");
|
||||
cctvID.put("107", "A20201113");
|
||||
cctvID.put("108", "A20211114");
|
||||
cctvID.put("301", "A20203115");
|
||||
cctvID.put("302", "A20213116");
|
||||
cctvID.put("303", "A10103117");
|
||||
cctvID.put("304", "A10103118");
|
||||
// cctvID.put("305", "폐쇄차로");
|
||||
// cctvID.put("306", "폐쇄차로");
|
||||
cctvID.put("307", "A1013119");
|
||||
cctvID.put("308", "A10103120");
|
||||
cctvID.put("309", "A10103121");
|
||||
cctvID.put("310", "A10103122");
|
||||
|
||||
String[] strarr = strOrgFile.split("_");
|
||||
|
||||
String tennel = strarr[3].substring(0, 1);
|
||||
String line = strarr[3].substring(1, 3);
|
||||
String dirc = strarr[3].substring(3);
|
||||
|
||||
// 미납 이미지 전송 경로
|
||||
mapDefault.put("image_path_desc", String.format("/data2/DOTR/%s/0%s/IMAGE/", strarr[0], tennel));
|
||||
mapDefault.put("image_path_desc_center", String.format("/DOTR/%s/0%s/IMAGE/", strarr[0], tennel));
|
||||
mapDefault.put("work_times", strarr[1]);
|
||||
mapDefault.put("seqno", strarr[2]);
|
||||
|
||||
int n = Integer .parseInt(strarr[2].substring(6, 8));
|
||||
|
||||
if(n >=40 && n< 50)
|
||||
mapDefault.put("collect_id", "40");
|
||||
else if(n >=60 && n< 70)
|
||||
mapDefault.put("collect_id", "40");
|
||||
else
|
||||
mapDefault.put("collect_id", String.format("%02d", n));
|
||||
|
||||
|
||||
jsonParam.put("camId", cctvID.get(tennel + line));
|
||||
jsonParam.put("pasageTime", strarr[0] + strarr[1]);
|
||||
jsonParam.put("vhcleNum", MakeCarNoHex2CarNo.makeCarNoHex2CarNo(strarr[4].trim()));
|
||||
jsonParam.put("vhcleKnd", strarr[5].substring(1, 2));
|
||||
jsonParam.put("vhcleColor", "0");
|
||||
jsonParam.put("allImagePath", "./car_img/"); // ???
|
||||
jsonParam.put("vhcleImagePath", "");
|
||||
jsonParam.put("nopltImagePath", "");
|
||||
jsonParam.put("inputKnd", "");
|
||||
jsonParam.put("vhcleDrc", dirc);
|
||||
jsonParam.put("recogCnfdncRate", "00");
|
||||
jsonParam.put("tfclneInfo", line);
|
||||
jsonParam.put("recogReqreTime", "000000");
|
||||
jsonParam.put("regltTrgetSe", "20");
|
||||
|
||||
System.out.println("=== : " + jsonParam.toJSONString());
|
||||
|
||||
StringBuilder pathOrg = new StringBuilder();
|
||||
pathOrg.append(g_strFTP[0]);
|
||||
/* pathOrg.append(strarr[0].substring(4, 6)); // day
|
||||
pathOrg.append("/");
|
||||
pathOrg.append(line); // line
|
||||
pathOrg.append("/");*/
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(0, 4));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(4, 6));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(6, 8));
|
||||
path.append("/");
|
||||
path.append(cctvID.get(tennel + line));
|
||||
path.append("/");
|
||||
path.append(strarr[1].substring(0, 2));
|
||||
path.append("/");
|
||||
|
||||
StringBuilder strbuf = new StringBuilder();
|
||||
strbuf.append("2");
|
||||
if (tennel.equals("1"))
|
||||
strbuf.append("NO");
|
||||
else if (tennel.equals("3"))
|
||||
strbuf.append("NT");
|
||||
else
|
||||
return null;
|
||||
|
||||
strbuf.append("TT");
|
||||
strbuf.append("C");
|
||||
strbuf.append("2");
|
||||
strbuf.append("_");
|
||||
|
||||
strbuf.append(cctvID.get(tennel + line));
|
||||
strbuf.append("_");
|
||||
|
||||
strbuf.append(strarr[0]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[1]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[2]);
|
||||
strbuf.append(".jpg");
|
||||
|
||||
mapDefault.put("image_file_new2", String.format("0%s%s%s%sS.JPG", tennel, line, strarr[0], strarr[1].substring(0, 6)));
|
||||
|
||||
mapDefault.put("image_path", pathOrg.toString());
|
||||
mapDefault.put("image_file", strbuf.toString());
|
||||
|
||||
return pathOrg.toString() + "#" + path.toString() + "#" + strbuf.toString();
|
||||
}
|
||||
|
||||
// 스케줄러에 인해 주기적으로 실행되는 함수.
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
state.add(new Date());
|
||||
|
||||
System.err.println("Instance " + key + " of DmbJob says: " + jobSays + ", and val is: " + myFloatValue
|
||||
+ ", state size:" + state.size() + "," + state.get(state.size() - 1));
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
String pathOrg = g_strFTP[0];
|
||||
findFileList(pathOrg, list);
|
||||
if (list.size() == 0) {
|
||||
System.out.println("=== 신규 이미지 없음");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> mapDefaultCar = new HashMap<String, String>();
|
||||
|
||||
String strNewFile = "";
|
||||
String[] strTargPath = null;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTP[1], g_strFTP[2], g_strFTP[3]);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
mapDefaultCar.clear();
|
||||
|
||||
// 1. renametomvoe -> 2. ftp upload -> 3. api 콜 -> 미납이면 이미지 전송 및 DB
|
||||
// 업데이트
|
||||
strNewFile = transFileName(list.get(i), jsonParam, mapDefaultCar);
|
||||
if (strNewFile == null || strNewFile.equals("") == true || jsonParam.size() == 0)
|
||||
continue;
|
||||
|
||||
strTargPath = strNewFile.split("#");
|
||||
|
||||
// 해당 디렉토리가 없을경우 디렉토리를 생성합니다.
|
||||
File Folder = new File(strTargPath[0] + "send/");
|
||||
if (!Folder.exists()) {
|
||||
try {
|
||||
Folder.mkdir(); // 폴더 생성합니다.
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("이미 폴더가 생성되어 있습니다.");
|
||||
}
|
||||
|
||||
// 2.
|
||||
File file = new File(strTargPath[0] + list.get(i));
|
||||
File fileNew = new File(strTargPath[0] + "send/" + strTargPath[2]);
|
||||
|
||||
if (fileNew.exists())
|
||||
fileNew.delete();
|
||||
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
|
||||
System.out.println("=== " + strTargPath[0]);
|
||||
System.out.println("=== " + strTargPath[1]);
|
||||
|
||||
try {
|
||||
|
||||
// 4. 미납처리...
|
||||
if (mapDefaultCar.get("collect_id").equals("40") == true) {
|
||||
DefaultCar(mapDefaultCar);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
sftp.disconnect();
|
||||
}
|
||||
|
||||
private void DefaultCar(Map<String, String>map) throws SQLException {
|
||||
|
||||
boolean isOk = false;
|
||||
|
||||
// 1. 이미지 전송
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTPColl[0], g_strFTPColl[1], g_strFTPColl[2]);
|
||||
System.out.print("============" + g_strFTPColl[3]);
|
||||
String str = map.get("image_path") + "send/";
|
||||
System.out.println("=== : "+ str);
|
||||
try {
|
||||
|
||||
File file = new File(str + map.get("image_file"));
|
||||
File fileNew = new File(str + map.get("image_file_new2"));
|
||||
try {
|
||||
sftp.mkdir2(map.get("image_path_desc").substring(1));
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
|
||||
if (fileNew.exists())
|
||||
fileNew.delete();
|
||||
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
|
||||
System.out.println("=== " + map.get("image_path_desc"));
|
||||
System.out.println("=== " + map.get("image_path_desc_center"));
|
||||
sftp.upload(map.get("image_path_desc"), fileNew);
|
||||
|
||||
isOk = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SftpException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
sftp.disconnect();
|
||||
}
|
||||
|
||||
|
||||
if(isOk == false)
|
||||
return;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
//현재 년도, 월, 일
|
||||
int year = cal.get ( Calendar.YEAR );
|
||||
int month = cal.get ( Calendar.MONTH ) + 1 ;
|
||||
int day = cal.get ( Calendar.DATE ) ;
|
||||
|
||||
|
||||
// DB update
|
||||
OracleConnection conn = null; // 통상 Connection으로 선언
|
||||
OraclePreparedStatement ps = null; // 통상 PreparedStatement로 선언
|
||||
|
||||
System.out.println("================================ 1 ");
|
||||
|
||||
int n = 0;
|
||||
try {
|
||||
conn = (OracleConnection) getOrclConn();
|
||||
|
||||
String sql = "";
|
||||
|
||||
sql = "update DEFAULT_FARE_READ_INFO ";
|
||||
sql = sql + " set CARS_STOP_PICTURE_FILE = ?, send_flag = '9' ";
|
||||
sql = sql + " where fare_office_id = '03' and booth_id = '07'";
|
||||
sql = sql + " and collect_id = '40' ";
|
||||
sql = sql + " and year = ? and month = ? and day = ?";
|
||||
sql = sql + " and WORK_TIMES = ? ";
|
||||
|
||||
System.out.println("=== : sql : " + sql);
|
||||
|
||||
|
||||
ps = (OraclePreparedStatement) conn.prepareStatement(sql);
|
||||
|
||||
ps.setString(1, map.get("image_file_new2"));
|
||||
|
||||
ps.setString(2,String.format("%04d", year));
|
||||
ps.setString(3,String.format("%02d", month));
|
||||
ps.setString(4,String.format("%02d", day));
|
||||
|
||||
ps.setString(5, map.get("work_times").substring(0, 6));
|
||||
|
||||
System.out.println(year);
|
||||
System.out.println(month);
|
||||
System.out.println(day);
|
||||
System.out.println(map.get("work_times").substring(0, 6));
|
||||
|
||||
n = ps.executeUpdate();
|
||||
|
||||
System.out.println(n);
|
||||
|
||||
ps.close();
|
||||
|
||||
sql = "update FARE_TERMINAL_INFO ";
|
||||
sql = sql + " set CARS_STOP_PICTURE_FILE = ?, send_flag = '0' ";
|
||||
sql = sql + " where fare_office_id = '03' and booth_id = '07'";
|
||||
sql = sql + " and collect_id = '40' ";
|
||||
sql = sql + " and year = ? and month = ? and day = ?";
|
||||
sql = sql + " and WORK_TIMES = ? ";
|
||||
|
||||
System.out.println("=== : sql : " + sql);
|
||||
|
||||
ps = (OraclePreparedStatement) conn.prepareStatement(sql);
|
||||
|
||||
ps.setString(1, map.get("image_file_new2"));
|
||||
|
||||
ps.setString(2,String.format("%04d", year));
|
||||
ps.setString(3,String.format("%02d", month));
|
||||
ps.setString(4,String.format("%02d", day));
|
||||
|
||||
ps.setString(5, map.get("work_times").substring(0, 6));
|
||||
|
||||
System.out.println(year);
|
||||
System.out.println(month);
|
||||
System.out.println(day);
|
||||
System.out.println(map.get("work_times").substring(0, 6));
|
||||
|
||||
n = ps.executeUpdate();
|
||||
|
||||
System.out.println(n);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
ps.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
private Connection getOrclConn() throws Exception {
|
||||
Class.forName(g_strDB[0]);
|
||||
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
||||
}
|
||||
|
||||
// 아래와 같이 setter 형식으로 값을 받을 수도 있고 혹은, datamap을 통해 얻을 수 있음
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<property name="severity" value="error" />
|
||||
|
||||
<!--module name="Header">
|
||||
<property name="headerFile" value="${checkstyle.header.file}" />
|
||||
<message key="header.missing" value="Source file missing Quartz license header" />
|
||||
<message key="header.mismatch" value="Quartz license header mismatch" />
|
||||
</module-->
|
||||
|
||||
<module name="FileTabCharacter" />
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="FileContentsHolder"/>
|
||||
</module>
|
||||
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="CHECKSTYLE_OFF\: ([\w\|]+)"/>
|
||||
<property name="onCommentFormat" value="CHECKSTYLE_ON\: ([\w\|]+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
public class ANPRStatusJob implements Job {
|
||||
private String jobSays;
|
||||
|
||||
private float myFloatValue;
|
||||
|
||||
private ArrayList<Date> state;
|
||||
|
||||
private String g_strTenel = "";
|
||||
|
||||
private List<String> g_listN1 = new ArrayList<>();
|
||||
|
||||
private List<String> g_listN3 = new ArrayList<>();
|
||||
|
||||
private final Logger logger = Logger.getLogger(AnprImageJob.class);
|
||||
|
||||
public ANPRStatusJob() {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
props.clear();
|
||||
props = null;
|
||||
System.out.println("===================== A");
|
||||
this.g_listN1.add("01");
|
||||
this.g_listN1.add("02");
|
||||
this.g_listN1.add("03");
|
||||
this.g_listN1.add("04");
|
||||
this.g_listN1.add("05");
|
||||
this.g_listN1.add("06");
|
||||
this.g_listN1.add("07");
|
||||
this.g_listN1.add("08");
|
||||
this.g_listN3.add("01");
|
||||
this.g_listN3.add("02");
|
||||
this.g_listN3.add("03");
|
||||
this.g_listN3.add("04");
|
||||
this.g_listN3.add("07");
|
||||
this.g_listN3.add("08");
|
||||
this.g_listN3.add("09");
|
||||
this.g_listN3.add("10");
|
||||
System.out.println("===================== B");
|
||||
} catch (Exception e) {
|
||||
this.logger.debug("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
this.state.add(new Date());
|
||||
this.logger.info("Instance " + key + " of DmbJob says: " + this.jobSays + ", and val is: " + this.myFloatValue +
|
||||
", state size:" + this.state.size() + "," + this.state.get(this.state.size() - 1));
|
||||
this.logger.debug("======== 차로개수 : " + this.g_listN3.size());
|
||||
List<String> list = new ArrayList<>();
|
||||
if (this.g_strTenel.equals("3")) {
|
||||
list.addAll(this.g_listN3);
|
||||
} else if (this.g_strTenel.equals("1")) {
|
||||
list.addAll(this.g_listN1);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\ANPRStatusJob.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,86 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
|
||||
public class AnprCarINfoSendFixDay {
|
||||
private String g_strTenel = "";
|
||||
|
||||
private List<String> g_listN1 = new ArrayList<>();
|
||||
|
||||
private List<String> g_listN3 = new ArrayList<>();
|
||||
|
||||
private final Logger logger = Logger.getLogger(AnprCarINfoSendFixDay.class);
|
||||
|
||||
public AnprCarINfoSendFixDay() {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
props.clear();
|
||||
props = null;
|
||||
System.out.println("===================== A");
|
||||
this.g_listN1.add("01");
|
||||
this.g_listN1.add("02");
|
||||
this.g_listN1.add("03");
|
||||
this.g_listN1.add("04");
|
||||
this.g_listN1.add("05");
|
||||
this.g_listN1.add("06");
|
||||
this.g_listN1.add("07");
|
||||
this.g_listN1.add("08");
|
||||
this.g_listN3.add("01");
|
||||
this.g_listN3.add("02");
|
||||
this.g_listN3.add("03");
|
||||
this.g_listN3.add("04");
|
||||
this.g_listN3.add("07");
|
||||
this.g_listN3.add("08");
|
||||
this.g_listN3.add("09");
|
||||
this.g_listN3.add("10");
|
||||
System.out.println("===================== B");
|
||||
} catch (Exception e) {
|
||||
this.logger.debug("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
this.logger.debug("======== 요금소 구분 : [" + this.g_strTenel + "]");
|
||||
this.logger.debug("======== 차로개수 : " + this.g_listN3.size());
|
||||
List<String> list = new ArrayList<>();
|
||||
if (this.g_strTenel.equals("3")) {
|
||||
list.addAll(this.g_listN3);
|
||||
} else if (this.g_strTenel.equals("1")) {
|
||||
list.addAll(this.g_listN1);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
SendThread obj = null;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
this.logger.info(String.format("%s차로 시작", new Object[] { list.get(i) }));
|
||||
obj = new SendThread(list.get(i));
|
||||
obj.runCarNoImageSend();
|
||||
try {
|
||||
Thread.sleep(5L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.logger.info(String.format("%s차로 끝", new Object[] { list.get(i) }));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AnprCarINfoSendFixDay obj = new AnprCarINfoSendFixDay();
|
||||
obj.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\AnprCarINfoSendFixDay.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,53 @@
|
||||
import java.util.ArrayList;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.ScheduleBuilder;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
public class AnprCarInfoSend {
|
||||
public static boolean g_isRunning = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "*/1 * * * * ?";
|
||||
if (args.length > 0)
|
||||
str = String.format("*/%s * * * * ?", new Object[] { args[0] });
|
||||
AnprCarInfoSend anpr = new AnprCarInfoSend();
|
||||
anpr.runAnprCarInfo(str);
|
||||
}
|
||||
|
||||
public void runAnprCarInfo(String str) {
|
||||
try {
|
||||
ArrayList<String> state = new ArrayList<>();
|
||||
JobDetail job = JobBuilder.newJob(AnprImageJob.class)
|
||||
.withIdentity("testJob")
|
||||
.usingJobData("jobSays", "ant.xml")
|
||||
.usingJobData("myFloatValue", Float.valueOf(3.141F)).build();
|
||||
job.getJobDataMap().put("state", state);
|
||||
CronTrigger cronTrigger =
|
||||
(CronTrigger)TriggerBuilder.newTrigger()
|
||||
.withIdentity("crontrigger", "crontriggergroup1")
|
||||
.withSchedule(
|
||||
(ScheduleBuilder)CronScheduleBuilder.cronSchedule("*/5 * * * * ?"))
|
||||
|
||||
.build();
|
||||
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
|
||||
Scheduler sch = stdSchedulerFactory.getScheduler();
|
||||
sch.start();
|
||||
sch.scheduleJob(job, (Trigger)cronTrigger);
|
||||
} catch (SchedulerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\AnprCarInfoSend.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,111 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
@DisallowConcurrentExecution
|
||||
public class AnprImageJob implements Job {
|
||||
private String jobSays;
|
||||
|
||||
private float myFloatValue;
|
||||
|
||||
private ArrayList<Date> state;
|
||||
|
||||
private String g_strTenel = "";
|
||||
|
||||
private List<String> g_listN1 = new ArrayList<>();
|
||||
|
||||
private List<String> g_listN3 = new ArrayList<>();
|
||||
|
||||
private final Logger logger = Logger.getLogger(AnprImageJob.class);
|
||||
|
||||
public AnprImageJob() {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
props.clear();
|
||||
props = null;
|
||||
System.out.println("===================== A");
|
||||
this.g_listN1.add("01");
|
||||
this.g_listN1.add("02");
|
||||
this.g_listN1.add("03");
|
||||
this.g_listN1.add("04");
|
||||
this.g_listN1.add("05");
|
||||
this.g_listN1.add("06");
|
||||
this.g_listN1.add("07");
|
||||
this.g_listN1.add("08");
|
||||
this.g_listN3.add("01");
|
||||
this.g_listN3.add("02");
|
||||
this.g_listN3.add("03");
|
||||
this.g_listN3.add("04");
|
||||
this.g_listN3.add("07");
|
||||
this.g_listN3.add("08");
|
||||
this.g_listN3.add("09");
|
||||
this.g_listN3.add("10");
|
||||
System.out.println("===================== B");
|
||||
} catch (Exception e) {
|
||||
this.logger.debug("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
this.state.add(new Date());
|
||||
this.logger.info("Instance " + key + " of DmbJob says: " + this.jobSays + ", and val is: " + this.myFloatValue +
|
||||
", state size:" + this.state.size() + "," + this.state.get(this.state.size() - 1));
|
||||
if (AnprCarInfoSend.g_isRunning) {
|
||||
this.logger.debug("======== 기존 쓰레드 미완료로 미수행");
|
||||
return;
|
||||
}
|
||||
AnprCarInfoSend.g_isRunning = true;
|
||||
this.logger.debug("======== 요금소 구분 : [" + this.g_strTenel + "]");
|
||||
this.logger.debug("======== 차로개수 : " + this.g_listN3.size());
|
||||
List<String> list = new ArrayList<>();
|
||||
if (this.g_strTenel.equals("3")) {
|
||||
list.addAll(this.g_listN3);
|
||||
} else if (this.g_strTenel.equals("1")) {
|
||||
list.addAll(this.g_listN1);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
SendThread obj = null;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
this.logger.info(String.format("%s차로 시작", new Object[] { list.get(i) }));
|
||||
obj = new SendThread(list.get(i));
|
||||
obj.runCarNoImageSend();
|
||||
this.logger.info(String.format("%s차로 끝", new Object[] { list.get(i) }));
|
||||
}
|
||||
AnprCarInfoSend.g_isRunning = false;
|
||||
}
|
||||
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\AnprImageJob.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,168 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class AnprStateSend extends Thread {
|
||||
private String[] g_strDB = new String[4];
|
||||
|
||||
private String[] g_strFTP = new String[6];
|
||||
|
||||
private String[] g_strFTPColl = new String[4];
|
||||
|
||||
private String g_strTenel = "";
|
||||
|
||||
private String g_strLane = "";
|
||||
|
||||
private String g_strApiUrAnprStatusl = "";
|
||||
|
||||
private final Logger logger = Logger.getLogger(AnprStateSend.class);
|
||||
|
||||
public AnprStateSend(String str) {
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strDB[0] = props.getProperty("db_driver");
|
||||
this.g_strDB[1] = props.getProperty("db_connect");
|
||||
this.g_strDB[2] = props.getProperty("db_id");
|
||||
this.g_strDB[3] = props.getProperty("db_pw");
|
||||
this.g_strFTP[0] = props.getProperty("path_org");
|
||||
this.g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
this.g_strFTP[2] = props.getProperty("ftp_id");
|
||||
this.g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
this.g_strFTP[4] = props.getProperty("api_url");
|
||||
this.g_strFTP[5] = props.getProperty("path_desc");
|
||||
this.g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
this.g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
this.g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
this.g_strFTPColl[3] = props.getProperty("center_ftp_ip");
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
this.g_strLane = str;
|
||||
this.g_strApiUrAnprStatusl = props.getProperty("api_url_status");
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
runCarNoImageSend();
|
||||
this.logger.debug(String.format("=======================================================", new Object[0]));
|
||||
}
|
||||
|
||||
public void runCarNoImageSend() {
|
||||
Map<String, String> cctvID = new HashMap<>();
|
||||
cctvID.put("101", "A10401001");
|
||||
cctvID.put("102", "A10301002");
|
||||
cctvID.put("103", "A10201003");
|
||||
cctvID.put("104", "A10101004");
|
||||
cctvID.put("105", "A10111005");
|
||||
cctvID.put("106", "A10211006");
|
||||
cctvID.put("107", "A10311007");
|
||||
cctvID.put("108", "A10411008");
|
||||
cctvID.put("301", "A10503001");
|
||||
cctvID.put("302", "A10403002");
|
||||
cctvID.put("303", "A10303003");
|
||||
cctvID.put("304", "A10203004");
|
||||
cctvID.put("307", "A10213005");
|
||||
cctvID.put("308", "A10313006");
|
||||
cctvID.put("309", "A10413007");
|
||||
cctvID.put("310", "A10513008");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMddHHmmss");
|
||||
String strDate = sdf.format(cal.getTime());
|
||||
this.logger.debug("===========" + strDate);
|
||||
List<String> temp = new ArrayList<>();
|
||||
temp.add("13");
|
||||
temp.add("11");
|
||||
temp.add("12");
|
||||
int n = (int)(Math.random() * 1000.0D) % 3;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
jsonParam.put("camId", cctvID.get(String.valueOf(this.g_strTenel) + this.g_strLane));
|
||||
jsonParam.put("colctTime", strDate);
|
||||
jsonParam.put("camConectSttus", "0");
|
||||
jsonParam.put("rtuTp", temp.get(n % 3));
|
||||
jsonParam.put("bxDoorSttus", "0");
|
||||
jsonParam.put("camSdCardSttus", "0");
|
||||
this.logger.debug("============== : " + jsonParam.toJSONString());
|
||||
callAnprCarnoSend(jsonParam.toJSONString());
|
||||
jsonParam.clear();
|
||||
}
|
||||
|
||||
private void callAnprCarnoSend(String strJson) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
URL url = new URL(this.g_strApiUrAnprStatusl);
|
||||
this.logger.debug("==== 수집서버 주소 : " + this.g_strApiUrAnprStatusl);
|
||||
connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(30000);
|
||||
connection.setReadTimeout(30000);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(strJson.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
int resCode = connection.getResponseCode();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String inputLine = null;
|
||||
this.logger.debug("==== : " + resCode);
|
||||
if (resCode == 200) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
while ((inputLine = br.readLine()) != null)
|
||||
sb.append(inputLine);
|
||||
this.logger.debug("==== " + sb.toString());
|
||||
} else if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
while ((inputLine = br.readLine()) != null)
|
||||
sb.append(inputLine);
|
||||
this.logger.debug("==== Http Error Resopnse : " + sb.toString());
|
||||
} else {
|
||||
this.logger.debug("==== Http Error Resopnse : " + sb.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.logger.debug("==== Http Error Resopnse : ");
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception exception) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\AnprStateSend.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,76 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.ScheduleBuilder;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
public class AnprStatusInfo {
|
||||
public static void main(String[] args) {
|
||||
String str = "*/1 * * * * ?";
|
||||
if (args.length > 0)
|
||||
str = String.format("*/%s * * * * ?", new Object[] { args[0] });
|
||||
AnprStateSend anpr = new AnprStateSend(str);
|
||||
anpr.runCarNoImageSend();
|
||||
}
|
||||
|
||||
public AnprStatusInfo() {
|
||||
Map<String, Boolean> mapIsRun_1 = new Hashtable<>();
|
||||
Map<String, Boolean> mapIsRun_3 = new Hashtable<>();
|
||||
mapIsRun_1.put("01", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("02", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("03", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("04", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("05", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("06", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("07", Boolean.valueOf(false));
|
||||
mapIsRun_1.put("08", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("01", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("02", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("03", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("04", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("05", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("06", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("07", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("08", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("09", Boolean.valueOf(false));
|
||||
mapIsRun_3.put("10", Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
public void runAnprCarInfo(String str) {
|
||||
try {
|
||||
ArrayList<String> state = new ArrayList<>();
|
||||
JobDetail job = JobBuilder.newJob(ANPRStatusJob.class)
|
||||
.withIdentity("testJob")
|
||||
.usingJobData("jobSays", "ant.xml")
|
||||
.usingJobData("myFloatValue", Float.valueOf(3.141F)).build();
|
||||
job.getJobDataMap().put("state", state);
|
||||
CronTrigger cronTrigger =
|
||||
(CronTrigger)TriggerBuilder.newTrigger()
|
||||
.withIdentity("crontrigger", "crontriggergroup1")
|
||||
.withSchedule(
|
||||
(ScheduleBuilder)CronScheduleBuilder.cronSchedule(" * /1 * * * *"))
|
||||
|
||||
.build();
|
||||
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
|
||||
Scheduler sch = stdSchedulerFactory.getScheduler();
|
||||
sch.start();
|
||||
sch.scheduleJob(job, (Trigger)cronTrigger);
|
||||
} catch (SchedulerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\AnprStatusInfo.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,126 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import oracle.jdbc.OracleConnection;
|
||||
import oracle.jdbc.OraclePreparedStatement;
|
||||
|
||||
public class DefaultCarImageDBUpdate {
|
||||
private static String[] g_strDB = new String[4];
|
||||
|
||||
private static String[] g_strFTP = new String[5];
|
||||
|
||||
private static String[] g_strFTPColl = new String[53];
|
||||
|
||||
public static void main(String[] args) {
|
||||
DefaultCarImageDBUpdate obj = new DefaultCarImageDBUpdate();
|
||||
Map<String, String> param = new HashMap<>();
|
||||
param.put("image_file", "030720190628150921S.JPG");
|
||||
param.put("work_times", "15092100");
|
||||
try {
|
||||
obj.runUpdate(param);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultCarImageDBUpdate() {
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
g_strDB[0] = props.getProperty("db_driver");
|
||||
g_strDB[1] = props.getProperty("db_connect");
|
||||
g_strDB[2] = props.getProperty("db_id");
|
||||
g_strDB[3] = props.getProperty("db_pw");
|
||||
g_strFTP[0] = props.getProperty("path_org");
|
||||
g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
g_strFTP[2] = props.getProperty("ftp_id");
|
||||
g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
g_strFTP[4] = props.getProperty("api_url");
|
||||
g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int date = cal.get(5);
|
||||
g_strFTP[0] = String.format("%s/%02d/07/", new Object[] { g_strFTP[0], Integer.valueOf(date) });
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Connection getOrclConn() throws Exception {
|
||||
Class.forName(g_strDB[0]);
|
||||
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
||||
}
|
||||
|
||||
public void runUpdate(Map<String, String> param) throws SQLException {
|
||||
OracleConnection conn = null;
|
||||
OraclePreparedStatement ps = null;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(1);
|
||||
int month = cal.get(2) + 1;
|
||||
int day = cal.get(5);
|
||||
int n = 0;
|
||||
try {
|
||||
conn = (OracleConnection)getOrclConn();
|
||||
String sql = "";
|
||||
sql = "update DEFAULT_FARE_READ_INFO ";
|
||||
sql = String.valueOf(sql) + " set CARS_STOP_PICTURE_FILE = ?, send_flag = '9' ";
|
||||
sql = String.valueOf(sql) + " where fare_office_id = '03' and booth_id = '07'";
|
||||
sql = String.valueOf(sql) + " and collect_id = '40' ";
|
||||
sql = String.valueOf(sql) + " and year = ? and month = ? and day = ?";
|
||||
sql = String.valueOf(sql) + " and WORK_TIMES = ? ";
|
||||
System.out.println("=== : sql : " + sql);
|
||||
ps = (OraclePreparedStatement)conn.prepareStatement(sql);
|
||||
ps.setString(1, param.get("image_file"));
|
||||
ps.setString(2, String.format("%04d", new Object[] { Integer.valueOf(year) }));
|
||||
ps.setString(3, String.format("%02d", new Object[] { Integer.valueOf(month) }));
|
||||
ps.setString(4, String.format("%02d", new Object[] { Integer.valueOf(day) }));
|
||||
ps.setString(5, ((String)param.get("work_times")).substring(0, 6));
|
||||
System.out.println(year);
|
||||
System.out.println(month);
|
||||
System.out.println(day);
|
||||
System.out.println(((String)param.get("work_times")).substring(0, 6));
|
||||
System.out.println(n);
|
||||
ps.close();
|
||||
sql = "update FARE_TERMINAL_INFO ";
|
||||
sql = String.valueOf(sql) + " set CARS_STOP_PICTURE_FILE = ?, send_flag = '0' ";
|
||||
sql = String.valueOf(sql) + " where fare_office_id = '03' and booth_id = '07'";
|
||||
sql = String.valueOf(sql) + " and collect_id = '40' ";
|
||||
sql = String.valueOf(sql) + " and year = ? and month = ? and day = ?";
|
||||
sql = String.valueOf(sql) + " and WORK_TIMES = ? ";
|
||||
System.out.println("=== : sql : " + sql);
|
||||
ps = (OraclePreparedStatement)conn.prepareStatement(sql);
|
||||
ps.setString(1, param.get("image_file"));
|
||||
ps.setString(2, String.format("%04d", new Object[] { Integer.valueOf(year) }));
|
||||
ps.setString(3, String.format("%02d", new Object[] { Integer.valueOf(month) }));
|
||||
ps.setString(4, String.format("%02d", new Object[] { Integer.valueOf(day) }));
|
||||
ps.setString(5, ((String)param.get("work_times")).substring(0, 6));
|
||||
System.out.println(year);
|
||||
System.out.println(month);
|
||||
System.out.println(day);
|
||||
System.out.println(((String)param.get("work_times")).substring(0, 6));
|
||||
System.out.println(n);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
ps.close();
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\DefaultCarImageDBUpdate.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,102 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
public class DumbJob implements Job {
|
||||
private String jobSays;
|
||||
|
||||
private float myFloatValue;
|
||||
|
||||
private ArrayList<Date> state;
|
||||
|
||||
private String g_strTenel = "";
|
||||
|
||||
private List<String> g_listN1 = new ArrayList<>();
|
||||
|
||||
private List<String> g_listN3 = new ArrayList<>();
|
||||
|
||||
private final Logger logger = Logger.getLogger(DumbJob.class);
|
||||
|
||||
public DumbJob() {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
props.clear();
|
||||
props = null;
|
||||
System.out.println("===================== A");
|
||||
this.g_listN1.add("01");
|
||||
this.g_listN1.add("02");
|
||||
this.g_listN1.add("03");
|
||||
this.g_listN1.add("04");
|
||||
this.g_listN1.add("05");
|
||||
this.g_listN1.add("06");
|
||||
this.g_listN1.add("07");
|
||||
this.g_listN1.add("08");
|
||||
this.g_listN3.add("01");
|
||||
this.g_listN3.add("02");
|
||||
this.g_listN3.add("03");
|
||||
this.g_listN3.add("04");
|
||||
this.g_listN3.add("07");
|
||||
this.g_listN3.add("08");
|
||||
this.g_listN3.add("09");
|
||||
this.g_listN3.add("10");
|
||||
System.out.println("===================== B");
|
||||
} catch (Exception e) {
|
||||
this.logger.debug("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
this.state.add(new Date());
|
||||
this.logger.info("Instance " + key + " of DmbJob says: " + this.jobSays + ", and val is: " + this.myFloatValue +
|
||||
", state size:" + this.state.size() + "," + this.state.get(this.state.size() - 1));
|
||||
this.logger.debug("======== 차로개수 : " + this.g_listN3.size());
|
||||
List<String> list = new ArrayList<>();
|
||||
if (this.g_strTenel.equals("3")) {
|
||||
list.addAll(this.g_listN3);
|
||||
} else if (this.g_strTenel.equals("1")) {
|
||||
list.addAll(this.g_listN1);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
SendThread obj = null;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
this.logger.debug(String.format("%s차로 시작", new Object[] { list.get(i) }));
|
||||
obj = new SendThread(list.get(i));
|
||||
obj.runCarNoImageSend();
|
||||
this.logger.debug(String.format("%s차로 끝", new Object[] { list.get(i) }));
|
||||
}
|
||||
}
|
||||
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\DumbJob.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,169 @@
|
||||
import com.jcraft.jsch.Channel;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class FTPUtil {
|
||||
private Session session = null;
|
||||
|
||||
private Channel channel = null;
|
||||
|
||||
private ChannelSftp channelSftp = null;
|
||||
|
||||
private static String[] g_strFTP = new String[5];
|
||||
|
||||
private final Logger logger = Logger.getLogger(FTPUtil.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
g_strFTP[0] = props.getProperty("path_org");
|
||||
g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
g_strFTP[2] = props.getProperty("ftp_id");
|
||||
g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
g_strFTP[4] = props.getProperty("path_desc");
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String path = g_strFTP[0];
|
||||
g_strFTP[4] = String.valueOf(g_strFTP[4]) + "/2019/07/36/A10100013/";
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(g_strFTP[1], g_strFTP[2], g_strFTP[3]);
|
||||
try {
|
||||
sftp.mkdir2(g_strFTP[4].substring(1));
|
||||
System.out.println("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
File file = new File(String.valueOf(path) + "/aaa.txt");
|
||||
try {
|
||||
sftp.upload(g_strFTP[4], file, "aaa.txt", "bbb.txt");
|
||||
} catch (SftpException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sftp.disconnect();
|
||||
}
|
||||
|
||||
public String mkdir(String path) throws SftpException {
|
||||
String[] pathArray = path.split("/");
|
||||
String currentDirectory = String.valueOf(this.channelSftp.pwd()) + "/";
|
||||
String totPathArray = "";
|
||||
for (int i = 0; i < pathArray.length; i++) {
|
||||
if (pathArray[i].length() != 0) {
|
||||
totPathArray = String.valueOf(totPathArray) + pathArray[i] + "/";
|
||||
String currentPath = String.valueOf(currentDirectory) + totPathArray;
|
||||
try {
|
||||
this.channelSftp.mkdir(currentPath);
|
||||
this.channelSftp.cd(currentPath);
|
||||
} catch (Exception e) {
|
||||
this.channelSftp.cd(currentPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.valueOf(currentDirectory) + "/" + totPathArray;
|
||||
}
|
||||
|
||||
public String mkdir2(String path) throws SftpException {
|
||||
String[] pathArray = path.split("/");
|
||||
String currentDirectory = "/";
|
||||
String totPathArray = "";
|
||||
for (int i = 0; i < pathArray.length; i++) {
|
||||
if (pathArray[i].length() != 0) {
|
||||
totPathArray = String.valueOf(totPathArray) + pathArray[i] + "/";
|
||||
String currentPath = String.valueOf(currentDirectory) + totPathArray;
|
||||
try {
|
||||
this.channelSftp.mkdir(currentPath);
|
||||
this.channelSftp.cd(currentPath);
|
||||
this.channelSftp.chmod(511, currentPath);
|
||||
} catch (Exception e) {
|
||||
this.channelSftp.cd(currentPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.valueOf(currentDirectory) + "/" + totPathArray;
|
||||
}
|
||||
|
||||
public void init(String url, String user, String password) {
|
||||
System.out.println(url);
|
||||
JSch jsch = new JSch();
|
||||
try {
|
||||
this.session = jsch.getSession(user, url);
|
||||
this.session.setPassword(password);
|
||||
Properties config = new Properties();
|
||||
config.put("StrictHostKeyChecking", "no");
|
||||
this.session.setConfig(config);
|
||||
this.session.connect();
|
||||
this.channel = this.session.openChannel("sftp");
|
||||
this.channel.connect();
|
||||
} catch (JSchException e) {
|
||||
this.logger.debug("Exception : " + e);
|
||||
}
|
||||
this.channelSftp = (ChannelSftp)this.channel;
|
||||
}
|
||||
|
||||
public void upload(String dir, File file, String old, String neo) throws SftpException, IOException {
|
||||
FileInputStream in = null;
|
||||
in = new FileInputStream(file);
|
||||
this.channelSftp.cd(dir);
|
||||
this.channelSftp.put(in, file.getName());
|
||||
in.close();
|
||||
this.channelSftp.chmod(511, dir);
|
||||
this.channelSftp.chmod(511, old);
|
||||
this.channelSftp.rename(old, neo);
|
||||
}
|
||||
|
||||
public void upload2(String dir, File file, String old, String neo) throws SftpException, IOException {
|
||||
FileInputStream in = null;
|
||||
this.logger.debug(String.format("============= :upload2 1 ", new Object[0]));
|
||||
in = new FileInputStream(file);
|
||||
this.logger.debug(String.format("============= :upload2 2 ", new Object[0]));
|
||||
this.logger.debug(dir);
|
||||
this.channelSftp.cd(dir);
|
||||
this.logger.debug(String.format("============= :upload2 3 ", new Object[0]));
|
||||
this.channelSftp.put(in, file.getName());
|
||||
this.logger.debug(String.format("============= :upload2 4 ", new Object[0]));
|
||||
in.close();
|
||||
this.logger.debug(String.format("============= :upload2 5 ", new Object[0]));
|
||||
this.channelSftp.rename(old, neo);
|
||||
this.logger.debug(String.format("============= :upload2 6 ", new Object[0]));
|
||||
}
|
||||
|
||||
public InputStream download(String dir, String fileNm) {
|
||||
InputStream in = null;
|
||||
String path = "...";
|
||||
try {
|
||||
this.channelSftp.cd(String.valueOf(path) + dir);
|
||||
in = this.channelSftp.get(fileNm);
|
||||
} catch (SftpException se) {
|
||||
this.logger.debug("Exception : " + se);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
this.channelSftp.quit();
|
||||
this.session.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\FTPUtil.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,117 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ImageNameTranse {
|
||||
private static String[] g_strDB = new String[4];
|
||||
|
||||
private static String[] g_strFTP = new String[5];
|
||||
|
||||
private static String[] g_strFTPColl = new String[53];
|
||||
|
||||
public static void main(String[] args) {
|
||||
DefaultCarImageDBUpdate obj = new DefaultCarImageDBUpdate();
|
||||
ImageNameTranse img = new ImageNameTranse();
|
||||
List<String> list = new ArrayList<>();
|
||||
String pathOrg = String.valueOf(g_strFTP[0]) + "z/";
|
||||
findFileList(pathOrg, list);
|
||||
if (list.size() == 0) {
|
||||
System.out.println("=== 신규 이미지 없음");
|
||||
return;
|
||||
}
|
||||
Map<String, String> cctvID = new HashMap<>();
|
||||
cctvID.put("A20201107", "101");
|
||||
cctvID.put("A20201109", "103");
|
||||
cctvID.put("A20211110", "104");
|
||||
cctvID.put("A20201111", "105");
|
||||
cctvID.put("A20211112", "106");
|
||||
cctvID.put("A20201113", "107");
|
||||
cctvID.put("A20211114", "108");
|
||||
cctvID.put("A20203115", "301");
|
||||
cctvID.put("A20213116", "302");
|
||||
cctvID.put("A10103117", "303");
|
||||
cctvID.put("A10103118", "304");
|
||||
cctvID.put("A1013119", "307");
|
||||
cctvID.put("A10103120", "308");
|
||||
cctvID.put("A10103121", "309");
|
||||
cctvID.put("A10103122", "310");
|
||||
String strImage = "";
|
||||
String[] strarry = null;
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
strarry = ((String)list.get(index)).split("_");
|
||||
strImage = String.format("0%s%s%sS.JPG", new Object[] { cctvID.get(strarry[1]), strarry[2], strarry[3].subSequence(0, 6) });
|
||||
map.put("image_file", strImage);
|
||||
map.put("year", strarry[2].substring(0, 4));
|
||||
map.put("month", strarry[2].substring(4, 6));
|
||||
map.put("day", strarry[2].substring(6, 8));
|
||||
map.put("work_times", strarry[3].substring(0, 6));
|
||||
try {
|
||||
obj.runUpdate(map);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ImageNameTranse() {
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
g_strDB[0] = props.getProperty("db_driver");
|
||||
g_strDB[1] = props.getProperty("db_connect");
|
||||
g_strDB[2] = props.getProperty("db_id");
|
||||
g_strDB[3] = props.getProperty("db_pw");
|
||||
g_strFTP[0] = props.getProperty("path_org");
|
||||
g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
g_strFTP[2] = props.getProperty("ftp_id");
|
||||
g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
g_strFTP[4] = props.getProperty("api_url");
|
||||
g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int date = cal.get(5);
|
||||
g_strFTP[0] = String.format("%s/%02d/07/", new Object[] { g_strFTP[0], Integer.valueOf(date) });
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void findFileList(String source, List<String> list) {
|
||||
File dir = new File(source);
|
||||
File[] fileList = dir.listFiles();
|
||||
try {
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
File file = fileList[i];
|
||||
System.out.println("=== = " + file.getName());
|
||||
if (file.isFile()) {
|
||||
String tempFileName = file.getName();
|
||||
if (tempFileName.toLowerCase().endsWith("jpg"))
|
||||
list.add(tempFileName);
|
||||
} else if (file.isDirectory() &&
|
||||
!file.getName().equals("send")) {
|
||||
findFileList(file.getCanonicalPath().toString(), list);
|
||||
}
|
||||
}
|
||||
} catch (IOException iOException) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\ImageNameTranse.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,162 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class LaneStateSend extends Thread {
|
||||
private String[] g_strDB = new String[4];
|
||||
|
||||
private String[] g_strFTP = new String[6];
|
||||
|
||||
private String[] g_strFTPColl = new String[4];
|
||||
|
||||
private String g_strTenel = "";
|
||||
|
||||
private String g_strLane = "";
|
||||
|
||||
public LaneStateSend(String str) {
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strDB[0] = props.getProperty("db_driver");
|
||||
this.g_strDB[1] = props.getProperty("db_connect");
|
||||
this.g_strDB[2] = props.getProperty("db_id");
|
||||
this.g_strDB[3] = props.getProperty("db_pw");
|
||||
this.g_strFTP[0] = props.getProperty("path_org");
|
||||
this.g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
this.g_strFTP[2] = props.getProperty("ftp_id");
|
||||
this.g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
this.g_strFTP[4] = props.getProperty("api_url");
|
||||
this.g_strFTP[5] = props.getProperty("path_desc");
|
||||
this.g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
this.g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
this.g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
this.g_strFTPColl[3] = props.getProperty("center_ftp_ip");
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
this.g_strLane = str;
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
runCarNoImageSend();
|
||||
System.out.println(String.format("=======================================================", new Object[0]));
|
||||
}
|
||||
|
||||
private void runCarNoImageSend() {
|
||||
Map<String, String> cctvID = new HashMap<>();
|
||||
cctvID.put("101", "A10401001");
|
||||
cctvID.put("102", "A10301002");
|
||||
cctvID.put("103", "A10201003");
|
||||
cctvID.put("104", "A10101004");
|
||||
cctvID.put("105", "A10111005");
|
||||
cctvID.put("106", "A10211006");
|
||||
cctvID.put("107", "A10311007");
|
||||
cctvID.put("108", "A10411008");
|
||||
cctvID.put("301", "A10503001");
|
||||
cctvID.put("302", "A10403002");
|
||||
cctvID.put("303", "A10303003");
|
||||
cctvID.put("304", "A10203004");
|
||||
cctvID.put("307", "A10213005");
|
||||
cctvID.put("308", "A10313006");
|
||||
cctvID.put("309", "A10413007");
|
||||
cctvID.put("310", "A10513008");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMddhhmmss");
|
||||
String strDate = sdf.format(cal.getTime());
|
||||
System.out.println("===========" + strDate);
|
||||
List<String> temp = new ArrayList<>();
|
||||
temp.add("13");
|
||||
temp.add("11");
|
||||
temp.add("12");
|
||||
int n = (int)(Math.random() * 1000.0D) % 3;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
jsonParam.put("camId", cctvID.get(String.valueOf(this.g_strTenel) + this.g_strLane));
|
||||
jsonParam.put("colctTime", strDate);
|
||||
jsonParam.put("camConectSttus", "0");
|
||||
jsonParam.put("rtuTp", temp.get(n % 3));
|
||||
jsonParam.put("bxDoorSttus", "0");
|
||||
jsonParam.put("camSdCardSttus", "0");
|
||||
System.out.println("============== : " + jsonParam.toJSONString());
|
||||
callAnprCarnoSend(jsonParam.toJSONString());
|
||||
jsonParam.clear();
|
||||
}
|
||||
|
||||
private void callAnprCarnoSend(String strJson) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
URL url = new URL(this.g_strFTP[4]);
|
||||
System.out.println("==== 수집서버 주소 : " + this.g_strFTP[4]);
|
||||
connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(30000);
|
||||
connection.setReadTimeout(30000);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(strJson.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
int resCode = connection.getResponseCode();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String inputLine = null;
|
||||
System.out.println("==== : " + resCode);
|
||||
if (resCode == 200) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
while ((inputLine = br.readLine()) != null)
|
||||
sb.append(inputLine);
|
||||
System.out.println("==== " + sb.toString());
|
||||
} else if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
while ((inputLine = br.readLine()) != null)
|
||||
sb.append(inputLine);
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
} else {
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("==== Http Error Resopnse : ");
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception exception) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\LaneStateSend.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,175 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MakeCarNoHex2CarNo {
|
||||
public static void main(String[] args) {
|
||||
String[] array = { "0004332416", "9902422041", "", "", "" };
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i].length() != 0)
|
||||
System.out.println(makeCarNoHex2CarNo(array[i]));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNumeric(String s) {
|
||||
return s.matches("-?\\d+(\\.\\d+)?");
|
||||
}
|
||||
|
||||
public static String makeCarNoHex2CarNo(String strCarNoHex) {
|
||||
if (strCarNoHex.contains("XXXX"))
|
||||
return "??????????";
|
||||
if (strCarNoHex.contains("0000000000"))
|
||||
return "??????????";
|
||||
StringBuffer strbuf = new StringBuffer();
|
||||
String strTemp = getRegionRev(strCarNoHex.substring(0, 2));
|
||||
strbuf.append(strTemp);
|
||||
if (!isNumeric(strTemp)) {
|
||||
int n = Integer.parseInt(strCarNoHex.substring(2, 4));
|
||||
strbuf.append(String.format("%02d", new Object[] { Integer.valueOf(n) }));
|
||||
} else {
|
||||
strbuf.append(strCarNoHex.substring(2, 4));
|
||||
}
|
||||
strbuf.append(getCarClassRev(strCarNoHex.substring(4, 6)));
|
||||
strbuf.append(strCarNoHex.substring(6, 10));
|
||||
return strbuf.toString();
|
||||
}
|
||||
|
||||
private static String getRegionRev(String str) {
|
||||
Map<String, String> mapRegion = new HashMap<>();
|
||||
mapRegion.put("00", "서울");
|
||||
mapRegion.put("01", "부산");
|
||||
mapRegion.put("02", "인천");
|
||||
mapRegion.put("03", "대구");
|
||||
mapRegion.put("04", "광주");
|
||||
mapRegion.put("05", "대전");
|
||||
mapRegion.put("06", "경기");
|
||||
mapRegion.put("07", "강원");
|
||||
mapRegion.put("08", "충북");
|
||||
mapRegion.put("09", "충남");
|
||||
mapRegion.put("10", "전북");
|
||||
mapRegion.put("11", "전남");
|
||||
mapRegion.put("12", "경북");
|
||||
mapRegion.put("13", "경남");
|
||||
mapRegion.put("14", "제주");
|
||||
mapRegion.put("15", "울산");
|
||||
mapRegion.put("16", "세종");
|
||||
mapRegion.put("81", "1");
|
||||
mapRegion.put("82", "2");
|
||||
mapRegion.put("83", "3");
|
||||
mapRegion.put("84", "4");
|
||||
mapRegion.put("85", "5");
|
||||
mapRegion.put("86", "6");
|
||||
mapRegion.put("87", "7");
|
||||
mapRegion.put("88", "8");
|
||||
mapRegion.put("89", "9");
|
||||
mapRegion.put("98", "외교");
|
||||
mapRegion.put("99", "");
|
||||
if (mapRegion.get(str) == null)
|
||||
return "??";
|
||||
return mapRegion.get(str);
|
||||
}
|
||||
|
||||
private static String getCarClassRev(String str) {
|
||||
Map<String, String> mapCarClass = new HashMap<>();
|
||||
mapCarClass.put("00", "가");
|
||||
mapCarClass.put("01", "나");
|
||||
mapCarClass.put("02", "다");
|
||||
mapCarClass.put("03", "라");
|
||||
mapCarClass.put("04", "마");
|
||||
mapCarClass.put("05", "바");
|
||||
mapCarClass.put("06", "사");
|
||||
mapCarClass.put("07", "아");
|
||||
mapCarClass.put("08", "자");
|
||||
mapCarClass.put("09", "자");
|
||||
mapCarClass.put("10", "카");
|
||||
mapCarClass.put("11", "타");
|
||||
mapCarClass.put("12", "파");
|
||||
mapCarClass.put("13", "하");
|
||||
mapCarClass.put("14", "거");
|
||||
mapCarClass.put("15", "너");
|
||||
mapCarClass.put("16", "더");
|
||||
mapCarClass.put("17", "러");
|
||||
mapCarClass.put("18", "머");
|
||||
mapCarClass.put("19", "버");
|
||||
mapCarClass.put("20", "서");
|
||||
mapCarClass.put("21", "어");
|
||||
mapCarClass.put("22", "저");
|
||||
mapCarClass.put("23", "처");
|
||||
mapCarClass.put("24", "커");
|
||||
mapCarClass.put("25", "터");
|
||||
mapCarClass.put("26", "퍼");
|
||||
mapCarClass.put("27", "허");
|
||||
mapCarClass.put("28", "고");
|
||||
mapCarClass.put("29", "노");
|
||||
mapCarClass.put("30", "도");
|
||||
mapCarClass.put("31", "로");
|
||||
mapCarClass.put("32", "모");
|
||||
mapCarClass.put("33", "보");
|
||||
mapCarClass.put("34", "소");
|
||||
mapCarClass.put("35", "오");
|
||||
mapCarClass.put("36", "조");
|
||||
mapCarClass.put("37", "초");
|
||||
mapCarClass.put("38", "코");
|
||||
mapCarClass.put("39", "토");
|
||||
mapCarClass.put("40", "포");
|
||||
mapCarClass.put("41", "호");
|
||||
mapCarClass.put("42", "구");
|
||||
mapCarClass.put("43", "누");
|
||||
mapCarClass.put("44", "두");
|
||||
mapCarClass.put("45", "루");
|
||||
mapCarClass.put("46", "무");
|
||||
mapCarClass.put("47", "부");
|
||||
mapCarClass.put("48", "수");
|
||||
mapCarClass.put("49", "우");
|
||||
mapCarClass.put("50", "주");
|
||||
mapCarClass.put("51", "추");
|
||||
mapCarClass.put("52", "쿠");
|
||||
mapCarClass.put("53", "투");
|
||||
mapCarClass.put("54", "푸");
|
||||
mapCarClass.put("55", "후");
|
||||
mapCarClass.put("56", "그");
|
||||
mapCarClass.put("57", "느");
|
||||
mapCarClass.put("58", "드");
|
||||
mapCarClass.put("59", "르");
|
||||
mapCarClass.put("60", "므");
|
||||
mapCarClass.put("61", "브");
|
||||
mapCarClass.put("62", "스");
|
||||
mapCarClass.put("63", "으");
|
||||
mapCarClass.put("64", "즈");
|
||||
mapCarClass.put("65", "츠");
|
||||
mapCarClass.put("66", "크");
|
||||
mapCarClass.put("67", "트");
|
||||
mapCarClass.put("68", "프");
|
||||
mapCarClass.put("69", "흐");
|
||||
mapCarClass.put("70", "기");
|
||||
mapCarClass.put("71", "니");
|
||||
mapCarClass.put("72", "디");
|
||||
mapCarClass.put("73", "리");
|
||||
mapCarClass.put("74", "미");
|
||||
mapCarClass.put("75", "비");
|
||||
mapCarClass.put("76", "시");
|
||||
mapCarClass.put("77", "이");
|
||||
mapCarClass.put("78", "지");
|
||||
mapCarClass.put("79", "치");
|
||||
mapCarClass.put("80", "키");
|
||||
mapCarClass.put("81", "티");
|
||||
mapCarClass.put("82", "피");
|
||||
mapCarClass.put("83", "히");
|
||||
mapCarClass.put("84", "육");
|
||||
mapCarClass.put("85", "해");
|
||||
mapCarClass.put("86", "공");
|
||||
mapCarClass.put("87", "국");
|
||||
mapCarClass.put("88", "합");
|
||||
mapCarClass.put("89", "_");
|
||||
mapCarClass.put("90", "배");
|
||||
mapCarClass.put("98", "외");
|
||||
if (mapCarClass.get(str) == null)
|
||||
return "????";
|
||||
return mapCarClass.get(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\MakeCarNoHex2CarNo.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,481 @@
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class SendThread extends Thread {
|
||||
private String[] g_strDB = new String[4];
|
||||
|
||||
private String[] g_strFTP = new String[6];
|
||||
|
||||
private String[] g_strFTPColl = new String[4];
|
||||
|
||||
private String g_strTenel = "";
|
||||
|
||||
private final Logger logger = Logger.getLogger(SendThread.class);
|
||||
|
||||
public void run() {
|
||||
runCarNoImageSend();
|
||||
this.logger.debug(String.format("=======================================================", new Object[0]));
|
||||
}
|
||||
|
||||
public SendThread(String str) {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
props.load(new BufferedInputStream(fis));
|
||||
this.g_strDB[0] = props.getProperty("db_driver");
|
||||
this.g_strDB[1] = props.getProperty("db_connect");
|
||||
this.g_strDB[2] = props.getProperty("db_id");
|
||||
this.g_strDB[3] = props.getProperty("db_pw");
|
||||
this.g_strFTP[0] = props.getProperty("path_org");
|
||||
this.g_strFTP[1] = props.getProperty("ftp_ip");
|
||||
this.g_strFTP[2] = props.getProperty("ftp_id");
|
||||
this.g_strFTP[3] = props.getProperty("ftp_pw");
|
||||
this.g_strFTP[4] = props.getProperty("api_url");
|
||||
this.g_strFTP[5] = props.getProperty("path_desc");
|
||||
this.g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
|
||||
this.g_strFTPColl[1] = props.getProperty("coll_ftp_id");
|
||||
this.g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
|
||||
this.g_strFTPColl[3] = props.getProperty("center_ftp_ip");
|
||||
this.g_strTenel = props.getProperty("tennel_no");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int date = cal.get(5);
|
||||
this.g_strFTP[0] = String.format("%s/%02d/%s/", new Object[] { this.g_strFTP[0], Integer.valueOf(date), str });
|
||||
this.logger.info("=== g_strFTP[0] : " + this.g_strFTP[0]);
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void findFileList(String source, List<String> list) {
|
||||
File dir = new File(source);
|
||||
File[] fileList = dir.listFiles();
|
||||
if (fileList == null) {
|
||||
this.logger.debug("======== 12.5 :::" + source);
|
||||
return;
|
||||
}
|
||||
int cnt = 10;
|
||||
if (fileList.length < cnt)
|
||||
cnt = fileList.length;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
File file = fileList[i];
|
||||
if (file.isFile()) {
|
||||
String tempFileName = file.getName();
|
||||
if (tempFileName.toLowerCase().endsWith(".jpg")) {
|
||||
list.add(tempFileName);
|
||||
this.logger.info("=== = " + file.getName());
|
||||
}
|
||||
} else if (file.isDirectory()) {
|
||||
this.logger.debug("디렉토리 이름 = " + file.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String transFileName(String strOrgFile, JSONObject jsonParam, Map<String, String> mapDefault) {
|
||||
Map<String, String> cctvID = new HashMap<>();
|
||||
cctvID.put("101", "A10401001");
|
||||
cctvID.put("102", "A10301002");
|
||||
cctvID.put("103", "A10201003");
|
||||
cctvID.put("104", "A10101004");
|
||||
cctvID.put("105", "A10111005");
|
||||
cctvID.put("106", "A10211006");
|
||||
cctvID.put("107", "A10311007");
|
||||
cctvID.put("108", "A10411008");
|
||||
cctvID.put("301", "A10503001");
|
||||
cctvID.put("302", "A10403002");
|
||||
cctvID.put("303", "A10303003");
|
||||
cctvID.put("304", "A10203004");
|
||||
cctvID.put("305", "폐쇄차로");
|
||||
cctvID.put("306", "폐쇄차로");
|
||||
cctvID.put("307", "A10213005");
|
||||
cctvID.put("308", "A10313006");
|
||||
cctvID.put("309", "A10413007");
|
||||
cctvID.put("310", "A10513008");
|
||||
String[] strarr = strOrgFile.split("_");
|
||||
String tennel = strarr[3].substring(0, 1);
|
||||
String line = strarr[3].substring(1, 3);
|
||||
String dirc = strarr[3].substring(3);
|
||||
dirc = cctvID.get(String.valueOf(tennel) + line);
|
||||
this.logger.debug("=============================X : " + dirc);
|
||||
dirc = dirc.substring(dirc.length() - 1);
|
||||
this.logger.debug("============================= Y : " + dirc);
|
||||
Map<String, String> mapDic = new HashMap<>();
|
||||
mapDic.put("1", "0");
|
||||
mapDic.put("2", "0");
|
||||
mapDic.put("3", "0");
|
||||
mapDic.put("4", "0");
|
||||
mapDic.put("5", "1");
|
||||
mapDic.put("6", "1");
|
||||
mapDic.put("7", "1");
|
||||
mapDic.put("8", "1");
|
||||
this.logger.debug("============================= Z : " + (String)mapDic.get(dirc));
|
||||
mapDefault.put("image_path_desc", String.format("/data2/DOTR/%s/0%s/IMAGE/", new Object[] { strarr[0], tennel }));
|
||||
mapDefault.put("image_path_desc_center", String.format(" /images/ANPRImage/cfs/%s/0%s/%s/", new Object[] { strarr[0].substring(0, 4), tennel, strarr[0] }));
|
||||
mapDefault.put("work_times", strarr[1]);
|
||||
mapDefault.put("seqno", strarr[2]);
|
||||
int n = Integer.parseInt(strarr[2].substring(6, 8));
|
||||
if (n >= 40 && n < 50) {
|
||||
mapDefault.put("collect_id", "40");
|
||||
} else if (n >= 60 && n < 70) {
|
||||
mapDefault.put("collect_id", "40");
|
||||
} else {
|
||||
mapDefault.put("collect_id", String.format("%02d", new Object[] { Integer.valueOf(n) }));
|
||||
}
|
||||
String strRate = "95";
|
||||
String strCarNo = MakeCarNoHex2CarNo.makeCarNoHex2CarNo(strarr[4].trim());
|
||||
if (strCarNo.contains("????") || strCarNo.contains("XXXX")) {
|
||||
strRate = "0";
|
||||
this.logger.debug("=== strCarNo : " + strCarNo + ", " + strarr[4].trim());
|
||||
}
|
||||
jsonParam.put("camId", cctvID.get(String.valueOf(tennel) + line));
|
||||
jsonParam.put("pasageTime", String.valueOf(strarr[0]) + strarr[1].substring(0, 6));
|
||||
jsonParam.put("vhcleNum", strCarNo);
|
||||
jsonParam.put("vhcleKnd", strarr[5].substring(0, 1));
|
||||
jsonParam.put("vhcleColor", "0");
|
||||
jsonParam.put("allImagePath", "./car_img/");
|
||||
jsonParam.put("vhcleImagePath", "");
|
||||
jsonParam.put("nopltImagePath", "");
|
||||
jsonParam.put("inputKnd", "");
|
||||
jsonParam.put("vhcleDrc", mapDic.get(dirc));
|
||||
jsonParam.put("recogCnfdncRate", strRate);
|
||||
jsonParam.put("tfclneInfo", line);
|
||||
jsonParam.put("recogReqreTime", "000000");
|
||||
jsonParam.put("regltTrgetSe", "20");
|
||||
jsonParam.put("boothId", line);
|
||||
jsonParam.put("fareId", "0" + tennel);
|
||||
StringBuilder pathOrg = new StringBuilder();
|
||||
pathOrg.append(this.g_strFTP[0]);
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(this.g_strFTP[5]);
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(0, 4));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(4, 6));
|
||||
path.append("/");
|
||||
path.append(strarr[0].substring(6, 8));
|
||||
path.append("/");
|
||||
path.append(cctvID.get(String.valueOf(tennel) + line));
|
||||
path.append("/");
|
||||
path.append(strarr[1].substring(0, 2));
|
||||
path.append("/");
|
||||
StringBuilder strbuf = new StringBuilder();
|
||||
strbuf.append("2");
|
||||
if (tennel.equals("1")) {
|
||||
strbuf.append("NO");
|
||||
} else if (tennel.equals("3")) {
|
||||
strbuf.append("NT");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
strbuf.append("TT");
|
||||
strbuf.append("C");
|
||||
strbuf.append("_");
|
||||
strbuf.append(cctvID.get(String.valueOf(tennel) + line));
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[0]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[1]);
|
||||
strbuf.append("_");
|
||||
strbuf.append(strarr[2]);
|
||||
strbuf.append(".jpg");
|
||||
mapDefault.put("image_file_new2",
|
||||
String.format("0%s%s%s%sS.JPG", new Object[] { tennel, line, strarr[0], strarr[1].substring(0, 6) }));
|
||||
mapDefault.put("image_path", pathOrg.toString());
|
||||
mapDefault.put("image_file", strOrgFile);
|
||||
this.logger.debug("=== pathOrg.toString() : " + pathOrg.toString());
|
||||
this.logger.debug("=== path.toString() : " + path.toString());
|
||||
this.logger.debug("=== strbuf.toString() : " + strbuf.toString());
|
||||
jsonParam.put("allImagePath", String.format("%s%s", new Object[] { path.toString().replace(String.valueOf(this.g_strFTP[5]) + "/", ""), strbuf.toString() }));
|
||||
this.logger.debug("=== : " + jsonParam.toJSONString());
|
||||
return String.valueOf(pathOrg.toString()) + "#" + path.toString() + "#" + strbuf.toString() + "#" + line;
|
||||
}
|
||||
|
||||
private int callAnprCarnoSend(String strJson) {
|
||||
int nResult = 0;
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
URL url = new URL(this.g_strFTP[4]);
|
||||
this.logger.info("==== 수집서버 주소 : " + this.g_strFTP[4]);
|
||||
connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(30000);
|
||||
connection.setReadTimeout(30000);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(strJson.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
int resCode = connection.getResponseCode();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String inputLine = null;
|
||||
this.logger.info("==== : " + resCode);
|
||||
if (resCode == 200) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
while ((inputLine = br.readLine()) != null)
|
||||
sb.append(inputLine);
|
||||
this.logger.info("==== " + sb.toString());
|
||||
} else if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
while ((inputLine = br.readLine()) != null)
|
||||
sb.append(inputLine);
|
||||
this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
||||
nResult = -1;
|
||||
} else {
|
||||
this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
||||
nResult = -1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
this.logger.info("==== Http Error Resopnse : ");
|
||||
nResult = -1;
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception exception) {}
|
||||
}
|
||||
return nResult;
|
||||
}
|
||||
|
||||
public void runCarNoImageSend() {
|
||||
List<String> list = new ArrayList<>();
|
||||
String pathOrg = this.g_strFTP[0];
|
||||
findFileList(pathOrg, list);
|
||||
if (list.size() == 0) {
|
||||
this.logger.debug("======== 21");
|
||||
this.logger.debug("신규 이미지 없음");
|
||||
return;
|
||||
}
|
||||
Map<String, String> mapNewTerminal = new HashMap<>();
|
||||
mapNewTerminal.put("101", "new");
|
||||
mapNewTerminal.put("102", "new");
|
||||
mapNewTerminal.put("103", "new");
|
||||
mapNewTerminal.put("104", "new");
|
||||
mapNewTerminal.put("105", "new");
|
||||
mapNewTerminal.put("106", "new");
|
||||
mapNewTerminal.put("107", "new");
|
||||
mapNewTerminal.put("108", "new");
|
||||
mapNewTerminal.put("301", "new");
|
||||
mapNewTerminal.put("302", "new");
|
||||
mapNewTerminal.put("303", "new");
|
||||
mapNewTerminal.put("304", "new");
|
||||
mapNewTerminal.put("307", "new");
|
||||
mapNewTerminal.put("308", "new");
|
||||
mapNewTerminal.put("309", "new");
|
||||
mapNewTerminal.put("310", "new");
|
||||
Map<String, String> mapDefaultCar = new HashMap<>();
|
||||
boolean isOk = false;
|
||||
String strNewFile = "";
|
||||
String[] strTargPath = null;
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(this.g_strFTP[1], this.g_strFTP[2], this.g_strFTP[3]);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
mapDefaultCar.clear();
|
||||
this.logger.debug("=== i : " + i + ", : " + (String)list.get(i));
|
||||
strNewFile = transFileName(list.get(i), jsonParam, mapDefaultCar);
|
||||
if (strNewFile == null || strNewFile.equals("") || jsonParam.size() == 0) {
|
||||
this.logger.debug("=== continue 1");
|
||||
} else {
|
||||
strTargPath = strNewFile.split("#");
|
||||
this.logger.debug("===" + strTargPath[0]);
|
||||
this.logger.debug("===" + strTargPath[1]);
|
||||
this.logger.debug("===" + strTargPath[2]);
|
||||
this.logger.debug("===" + strTargPath[3]);
|
||||
File Folder = new File(String.valueOf(strTargPath[0]) + "send/");
|
||||
if (!Folder.exists()) {
|
||||
try {
|
||||
Folder.mkdir();
|
||||
this.logger.debug("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
} else {
|
||||
this.logger.debug("이미 폴더가 생성되어 있습니다.");
|
||||
}
|
||||
File FolderErr = new File(String.valueOf(strTargPath[0]) + "error/");
|
||||
if (!FolderErr.exists()) {
|
||||
try {
|
||||
FolderErr.mkdir();
|
||||
this.logger.debug("폴더가 생성되었습니다.(error)");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
} else {
|
||||
this.logger.debug("이미 폴더가 생성되어 있습니다.");
|
||||
}
|
||||
File file = new File(String.valueOf(strTargPath[0]) + (String)list.get(i));
|
||||
File fileNew = new File(String.valueOf(strTargPath[0]) + "send/" + (String)list.get(i));
|
||||
File fileErr = new File(String.valueOf(strTargPath[0]) + "error/" + (String)list.get(i));
|
||||
if (fileNew.exists())
|
||||
fileNew.delete();
|
||||
if (fileErr.exists())
|
||||
fileErr.delete();
|
||||
this.logger.debug("=== 3 : " + strTargPath[0]);
|
||||
this.logger.debug("=== 4 : " + strTargPath[1]);
|
||||
isOk = false;
|
||||
try {
|
||||
sftp.mkdir2(strTargPath[1].substring(1));
|
||||
this.logger.debug("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
this.logger.debug(String.format("============= : 업로드 전 ", new Object[0]));
|
||||
try {
|
||||
sftp.upload(strTargPath[1], file, list.get(i), strTargPath[2]);
|
||||
this.logger.debug(String.format("============= : 업로드 성공 ", new Object[0]));
|
||||
isOk = true;
|
||||
} catch (SftpException e) {
|
||||
this.logger.info("=== Exception 1 : " + e);
|
||||
} catch (IOException e) {
|
||||
this.logger.info("=== Exception 2 : " + e);
|
||||
}
|
||||
this.logger.debug(String.format("============= : 업로드 후 ", new Object[0]));
|
||||
if (isOk) {
|
||||
int nResult = callAnprCarnoSend(jsonParam.toJSONString());
|
||||
jsonParam.clear();
|
||||
this.logger.debug(String.format("============= : 미납체크 전", new Object[0]));
|
||||
String strTemp = String.valueOf(this.g_strTenel) + strTargPath[3];
|
||||
if (((String)mapNewTerminal.get(strTemp)).equals("new")) {
|
||||
this.logger.debug("============= : 미납여부 확인 후 : " + (String)mapDefaultCar.get("collect_id"));
|
||||
if (((String)mapDefaultCar.get("collect_id")).equals("40")) {
|
||||
this.logger.debug(String.format("=== update param : %s, %s, %s", new Object[] { strTargPath[1], file, list.get(i), strTargPath[2] }));
|
||||
this.logger.debug("==== 미납 수행 시작");
|
||||
try {
|
||||
DefaultCarCenter(strTargPath[3], file, mapDefaultCar);
|
||||
} catch (SQLException e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
}
|
||||
this.logger.debug("==== 미납 수행 완료");
|
||||
}
|
||||
}
|
||||
this.logger.debug(String.format("============= : 미납체크 후", new Object[0]));
|
||||
if (file.exists())
|
||||
if (nResult < 0) {
|
||||
file.renameTo(fileErr);
|
||||
} else {
|
||||
file.renameTo(fileNew);
|
||||
}
|
||||
if (file.exists())
|
||||
file.renameTo(fileNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
sftp.disconnect();
|
||||
}
|
||||
|
||||
private void DefaultCar(String strBoothId, File file, Map<String, String> map) throws SQLException {
|
||||
this.logger.info(String.format("============= : DefaultCar 시작", new Object[0]));
|
||||
boolean isOk = false;
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(this.g_strFTPColl[0], this.g_strFTPColl[1], this.g_strFTPColl[2]);
|
||||
this.logger.debug("=== : " + (String)map.get("image_path"));
|
||||
try {
|
||||
try {
|
||||
sftp.mkdir2(((String)map.get("image_path_desc")).substring(1));
|
||||
this.logger.debug("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
this.logger.debug("=== " + (String)map.get("image_path_desc"));
|
||||
this.logger.debug("=== image_file_new2 : " + (String)map.get("image_file_new2"));
|
||||
this.logger.info(String.format("============= : DefaultCar 파일전송 전 ", new Object[0]));
|
||||
this.logger.debug(String.format("=== update2 param : %s, %s, %s", new Object[] { map.get("image_path_desc"), map.get("image_file"), map.get("image_file_new2") }));
|
||||
sftp.upload2(map.get("image_path_desc"), file, map.get("image_file"), map.get("image_file_new2"));
|
||||
this.logger.info(String.format("============= : DefaultCar 파일전송 후 ", new Object[0]));
|
||||
isOk = true;
|
||||
} catch (IOException e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
} catch (SftpException e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
} finally {
|
||||
sftp.disconnect();
|
||||
}
|
||||
if (!isOk)
|
||||
return;
|
||||
this.logger.info(String.format("============= : DefaultCar 끝", new Object[0]));
|
||||
}
|
||||
|
||||
private void DefaultCarCenter(String strBoothId, File file, Map<String, String> map) throws SQLException {
|
||||
boolean isOk = false;
|
||||
FTPUtil sftp = new FTPUtil();
|
||||
sftp.init(this.g_strFTP[1], this.g_strFTP[2], this.g_strFTP[3]);
|
||||
this.logger.debug("============ Center ftp connect");
|
||||
try {
|
||||
try {
|
||||
sftp.mkdir2(((String)map.get("image_path_desc_center")).substring(1));
|
||||
this.logger.debug("폴더가 생성되었습니다.");
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
this.logger.debug("=== " + (String)map.get("image_path_desc_center"));
|
||||
this.logger.debug("=== image_file_new2 : " + (String)map.get("image_file_new2"));
|
||||
this.logger.info(String.format("============= : DefaultCarCenter 파일전송 전 ", new Object[0]));
|
||||
this.logger.debug(String.format("=== update2 param : %s, %s, %s", new Object[] { map.get("image_path_desc_center"), map.get("image_file"), map.get("image_file_new2") }));
|
||||
sftp.upload2(((String)map.get("image_path_desc_center")).toString().trim(), file, map.get("image_file"), map.get("image_file_new2"));
|
||||
this.logger.info(String.format("============= : DefaultCarCenter 파일전송 후 ", new Object[0]));
|
||||
isOk = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
this.logger.info("Exception : " + e);
|
||||
} catch (SftpException e) {
|
||||
e.printStackTrace();
|
||||
this.logger.info("Exception : " + e);
|
||||
} finally {
|
||||
sftp.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private Connection getOrclConn() throws Exception {
|
||||
Class.forName(this.g_strDB[0]);
|
||||
return DriverManager.getConnection(this.g_strDB[1], this.g_strDB[2], this.g_strDB[3]);
|
||||
}
|
||||
|
||||
private Connection getOrclConnCenter() throws Exception {
|
||||
Class.forName(this.g_strDB[0]);
|
||||
return DriverManager.getConnection("jdbc:oracle:thin:@150.50.46.11:1521:Ora91", "NAMSAN", "namsan");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\SendThread.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,38 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
subDirList("./", list);
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
System.out.println("=== : " + (String)list.get(i));
|
||||
}
|
||||
|
||||
public static void subDirList(String source, List<String> list) {
|
||||
File dir = new File(source);
|
||||
File[] fileList = dir.listFiles();
|
||||
try {
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
File file = fileList[i];
|
||||
if (file.isFile()) {
|
||||
String tempFileName = file.getName();
|
||||
if (tempFileName.toLowerCase().endsWith("jpg"))
|
||||
list.add(tempFileName);
|
||||
System.out.println("\t 파일 이름 = " + file.getName());
|
||||
} else if (file.isDirectory()) {
|
||||
System.out.println("디렉토리 이름 = " + file.getName());
|
||||
subDirList(file.getCanonicalPath().toString(), list);
|
||||
}
|
||||
}
|
||||
} catch (IOException iOException) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\Test.class
|
||||
* Java compiler version: 8 (52.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,74 @@
|
||||
package examples;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Throwable {
|
||||
Properties fp = new Properties();
|
||||
InputStream ras = Main.class.getResourceAsStream("examples.properties");
|
||||
if (ras != null) {
|
||||
fp.load(ras);
|
||||
} else {
|
||||
System.err.println("[Cannot find examples.properties file, so aliases cannot be used]");
|
||||
}
|
||||
if (args.length == 0) {
|
||||
if ((Thread.currentThread().getStackTrace()).length > 2) {
|
||||
System.out.println("Usage: mvn -q exec:java -Dexec.arguments=<alias or exampleClass>,<exampleClass parameters> (comma-separated, no spaces)");
|
||||
System.out.println("Or : mvn -q exec:java -Dexec.args=\"<alias or exampleClass> <exampleClass parameters>\" (space separated)");
|
||||
} else if (fromJar()) {
|
||||
System.out.println("Usage: java -jar commons-net-examples-m.n.jar <alias or exampleClass> <exampleClass parameters>");
|
||||
} else {
|
||||
System.out.println("Usage: java -cp target/classes examples/Main <alias or exampleClass> <exampleClass parameters>");
|
||||
}
|
||||
List<String> l = (List)Collections.list(fp.propertyNames());
|
||||
if (l.isEmpty())
|
||||
return;
|
||||
Collections.sort(l);
|
||||
System.out.println("\nAliases and their classes:");
|
||||
for (String s : l) {
|
||||
System.out.printf("%-25s %s%n", new Object[] { s, fp.getProperty(s) });
|
||||
}
|
||||
return;
|
||||
}
|
||||
String shortName = args[0];
|
||||
String fullName = fp.getProperty(shortName);
|
||||
if (fullName == null)
|
||||
fullName = shortName;
|
||||
fullName = fullName.replace('/', '.');
|
||||
try {
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
Method m = clazz.getDeclaredMethod("main", new Class[] { args.getClass() });
|
||||
String[] args2 = new String[args.length - 1];
|
||||
System.arraycopy(args, 1, args2, 0, args2.length);
|
||||
try {
|
||||
m.invoke(null, new Object[] { args2 });
|
||||
} catch (InvocationTargetException ite) {
|
||||
Throwable cause = ite.getCause();
|
||||
if (cause != null)
|
||||
throw cause;
|
||||
throw ite;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean fromJar() {
|
||||
CodeSource codeSource = Main.class.getProtectionDomain().getCodeSource();
|
||||
if (codeSource != null)
|
||||
return codeSource.getLocation().getFile().endsWith(".jar");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\Main.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,40 @@
|
||||
package examples.cidr;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
import org.apache.commons.net.util.SubnetUtils;
|
||||
|
||||
public class SubnetUtilsExample {
|
||||
public static void main(String[] args) {
|
||||
String subnet = "192.168.0.3/31";
|
||||
SubnetUtils utils = new SubnetUtils(subnet);
|
||||
SubnetUtils.SubnetInfo info = utils.getInfo();
|
||||
System.out.printf("Subnet Information for %s:\n", new Object[] { subnet });
|
||||
System.out.println("--------------------------------------");
|
||||
System.out.printf("IP Address:\t\t\t%s\t[%s]\n", new Object[] { info.getAddress(), Integer.toBinaryString(info.asInteger(info.getAddress())) });
|
||||
System.out.printf("Netmask:\t\t\t%s\t[%s]\n", new Object[] { info.getNetmask(), Integer.toBinaryString(info.asInteger(info.getNetmask())) });
|
||||
System.out.printf("CIDR Representation:\t\t%s\n\n", new Object[] { info.getCidrSignature() });
|
||||
System.out.printf("Supplied IP Address:\t\t%s\n\n", new Object[] { info.getAddress() });
|
||||
System.out.printf("Network Address:\t\t%s\t[%s]\n", new Object[] { info.getNetworkAddress(), Integer.toBinaryString(info.asInteger(info.getNetworkAddress())) });
|
||||
System.out.printf("Broadcast Address:\t\t%s\t[%s]\n", new Object[] { info.getBroadcastAddress(), Integer.toBinaryString(info.asInteger(info.getBroadcastAddress())) });
|
||||
System.out.printf("Low Address:\t\t\t%s\t[%s]\n", new Object[] { info.getLowAddress(), Integer.toBinaryString(info.asInteger(info.getLowAddress())) });
|
||||
System.out.printf("High Address:\t\t\t%s\t[%s]\n", new Object[] { info.getHighAddress(), Integer.toBinaryString(info.asInteger(info.getHighAddress())) });
|
||||
System.out.printf("Total usable addresses: \t%d\n", new Object[] { Long.valueOf(info.getAddressCountLong()) });
|
||||
System.out.printf("Address List: %s\n\n", new Object[] { Arrays.toString((Object[])info.getAllAddresses()) });
|
||||
String prompt = "Enter an IP address (e.g. 192.168.0.10):";
|
||||
System.out.println("Enter an IP address (e.g. 192.168.0.10):");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
while (scanner.hasNextLine()) {
|
||||
String address = scanner.nextLine();
|
||||
System.out.println("The IP address [" + address + "] is " + (info.isInRange(address) ? "" : "not ") + "within the subnet [" + subnet + "]");
|
||||
System.out.println("Enter an IP address (e.g. 192.168.0.10):");
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\cidr\SubnetUtilsExample.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# Apache Commons Net Examples Property file
|
||||
################################################################################
|
||||
|
||||
## Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
## contributor license agreements. See the NOTICE file distributed with
|
||||
## this work for additional information regarding copyright ownership.
|
||||
## The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
## (the "License"); you may not use this file except in compliance with
|
||||
## the License. You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
|
||||
# List of aliases for example class names.
|
||||
# Note that the "/" separators are converted to "."
|
||||
|
||||
# alias full class name
|
||||
SubnetUtilsExample examples/cidr/SubnetUtilsExample
|
||||
FTPClientExample examples/ftp/FTPClientExample
|
||||
ServerToServerFTP examples/ftp/ServerToServerFTP
|
||||
TFTPExample examples/ftp/TFTPExample
|
||||
IMAPExportMbox examples/mail/IMAPExportMbox
|
||||
IMAPImportMbox examples/mail/IMAPImportMbox
|
||||
IMAPMail examples/mail/IMAPMail
|
||||
POP3Mail examples/mail/POP3Mail
|
||||
SMTPMail examples/mail/SMTPMail
|
||||
ArticleReader examples/nntp/ArticleReader
|
||||
ExtendedNNTPOps examples/nntp/ExtendedNNTPOps
|
||||
ListNewsgroups examples/nntp/ListNewsgroups
|
||||
MessageThreading examples/nntp/MessageThreading
|
||||
PostMessage examples/nntp/PostMessage
|
||||
NTPClient examples/ntp/NTPClient
|
||||
SimpleNTPServer examples/ntp/SimpleNTPServer
|
||||
TimeClient examples/ntp/TimeClient
|
||||
TelnetClientExample examples/telnet/TelnetClientExample
|
||||
WeatherTelnet examples/telnet/WeatherTelnet
|
||||
chargen examples/unix/chargen
|
||||
daytime examples/unix/daytime
|
||||
echo examples/unix/echo
|
||||
finger examples/unix/finger
|
||||
fwhois examples/unix/fwhois
|
||||
rdate examples/unix/rdate
|
||||
rexec examples/unix/rexec
|
||||
rlogin examples/unix/rlogin
|
||||
rshell examples/unix/rshell
|
||||
@ -0,0 +1,265 @@
|
||||
package examples.ftp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||
import org.apache.commons.net.ftp.FTPConnectionClosedException;
|
||||
import org.apache.commons.net.ftp.FTPHTTPClient;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
import org.apache.commons.net.ftp.FTPSClient;
|
||||
import org.apache.commons.net.io.CopyStreamEvent;
|
||||
import org.apache.commons.net.io.CopyStreamListener;
|
||||
import org.apache.commons.net.util.TrustManagerUtils;
|
||||
|
||||
public final class FTPClientExample {
|
||||
public static final String USAGE = "Expected Parameters: [options] <hostname> <username> <password> [<remote file> [<local file>]]\n\nDefault behavior is to download a file and use ASCII transfer mode.\n\t-a - use local active mode (default is local passive)\n\t-A - anonymous login (omit username and password parameters)\n\t-b - use binary transfer mode\n\t-c cmd - issue arbitrary command (remote is used as a parameter if provided) \n\t-d - list directory details using MLSD (remote is used as the pathname if provided)\n\t-e - use EPSV with IPv4 (default false)\n\t-E - encoding to use for control channel\n\t-f - issue FEAT command (remote and local files are ignored)\n\t-h - list hidden files (applies to -l and -n only)\n\t-k secs - use keep-alive timer (setControlKeepAliveTimeout)\n\t-l - list files using LIST (remote is used as the pathname if provided)\n\t Files are listed twice: first in raw mode, then as the formatted parsed data.\n\t N.B. if the wrong server-type is used, output may be lost. Use -U or -S as necessary.\n\t-L - use lenient future dates (server dates may be up to 1 day into future)\n\t-m - list file details using MDTM (remote is used as the pathname if provided)\n\t-n - list file names using NLST (remote is used as the pathname if provided)\n\t-p true|false|protocol[,true|false] - use FTPSClient with the specified protocol and/or isImplicit setting\n\t-s - store file on server (upload)\n\t-S - systemType set server system type (e.g. UNIX VMS WINDOWS)\n\t-t - list file details using MLST (remote is used as the pathname if provided)\n\t-U - save unparseable responses\n\t-w msec - wait time for keep-alive reply (setControlKeepAliveReplyTimeout)\n\t-T all|valid|none - use one of the built-in TrustManager implementations (none = JVM default)\n\t-y format - set default date format string\n\t-Y format - set recent date format string\n\t-Z timezone - set the server timezone for parsing LIST responses\n\t-z timezone - set the timezone for displaying MDTM, LIST, MLSD, MLST responses\n\t-PrH server[:port] - HTTP Proxy host and optional port[80] \n\t-PrU user - HTTP Proxy server username\n\t-PrP password - HTTP Proxy server password\n\t-# - add hash display during transfers\n";
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
FTPSClient fTPSClient = null;
|
||||
FTPClientConfig config;
|
||||
boolean storeFile = false, binaryTransfer = false, error = false, listFiles = false, listNames = false, hidden = false;
|
||||
boolean localActive = false, useEpsvWithIPv4 = false, feat = false, printHash = false;
|
||||
boolean mlst = false, mlsd = false, mdtm = false, saveUnparseable = false;
|
||||
boolean lenient = false;
|
||||
long keepAliveTimeout = -1L;
|
||||
int controlKeepAliveReplyTimeout = -1;
|
||||
int minParams = 5;
|
||||
String protocol = null;
|
||||
String doCommand = null;
|
||||
String trustmgr = null;
|
||||
String proxyHost = null;
|
||||
int proxyPort = 80;
|
||||
String proxyUser = null;
|
||||
String proxyPassword = null;
|
||||
String username = null;
|
||||
String password = null;
|
||||
String encoding = null;
|
||||
String serverTimeZoneId = null;
|
||||
String displayTimeZoneId = null;
|
||||
String serverType = null;
|
||||
String defaultDateFormat = null;
|
||||
String recentDateFormat = null;
|
||||
int base = 0;
|
||||
for (base = 0; base < args.length; base++) {
|
||||
if (args[base].equals("-s")) {
|
||||
storeFile = true;
|
||||
} else if (args[base].equals("-a")) {
|
||||
localActive = true;
|
||||
} else if (args[base].equals("-A")) {
|
||||
username = "anonymous";
|
||||
password = System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName();
|
||||
} else if (args[base].equals("-b")) {
|
||||
binaryTransfer = true;
|
||||
} else if (args[base].equals("-c")) {
|
||||
doCommand = args[++base];
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-d")) {
|
||||
mlsd = true;
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-e")) {
|
||||
useEpsvWithIPv4 = true;
|
||||
} else if (args[base].equals("-E")) {
|
||||
encoding = args[++base];
|
||||
} else if (args[base].equals("-f")) {
|
||||
feat = true;
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-h")) {
|
||||
hidden = true;
|
||||
} else if (args[base].equals("-k")) {
|
||||
keepAliveTimeout = Long.parseLong(args[++base]);
|
||||
} else if (args[base].equals("-l")) {
|
||||
listFiles = true;
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-m")) {
|
||||
mdtm = true;
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-L")) {
|
||||
lenient = true;
|
||||
} else if (args[base].equals("-n")) {
|
||||
listNames = true;
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-p")) {
|
||||
protocol = args[++base];
|
||||
} else if (args[base].equals("-S")) {
|
||||
serverType = args[++base];
|
||||
} else if (args[base].equals("-t")) {
|
||||
mlst = true;
|
||||
minParams = 3;
|
||||
} else if (args[base].equals("-U")) {
|
||||
saveUnparseable = true;
|
||||
} else if (args[base].equals("-w")) {
|
||||
controlKeepAliveReplyTimeout = Integer.parseInt(args[++base]);
|
||||
} else if (args[base].equals("-T")) {
|
||||
trustmgr = args[++base];
|
||||
} else if (args[base].equals("-y")) {
|
||||
defaultDateFormat = args[++base];
|
||||
} else if (args[base].equals("-Y")) {
|
||||
recentDateFormat = args[++base];
|
||||
} else if (args[base].equals("-Z")) {
|
||||
serverTimeZoneId = args[++base];
|
||||
} else if (args[base].equals("-z")) {
|
||||
displayTimeZoneId = args[++base];
|
||||
} else if (args[base].equals("-PrH")) {
|
||||
proxyHost = args[++base];
|
||||
String[] arrayOfString = proxyHost.split(":");
|
||||
if (arrayOfString.length == 2) {
|
||||
proxyHost = arrayOfString[0];
|
||||
proxyPort = Integer.parseInt(arrayOfString[1]);
|
||||
}
|
||||
} else if (args[base].equals("-PrU")) {
|
||||
proxyUser = args[++base];
|
||||
} else if (args[base].equals("-PrP")) {
|
||||
proxyPassword = args[++base];
|
||||
} else if (args[base].equals("-#")) {
|
||||
printHash = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int remain = args.length - base;
|
||||
if (username != null)
|
||||
minParams -= 2;
|
||||
if (remain < minParams) {
|
||||
if (args.length > 0)
|
||||
System.err.println("Actual Parameters: " + Arrays.toString((Object[])args));
|
||||
System.err.println("Expected Parameters: [options] <hostname> <username> <password> [<remote file> [<local file>]]\n\nDefault behavior is to download a file and use ASCII transfer mode.\n\t-a - use local active mode (default is local passive)\n\t-A - anonymous login (omit username and password parameters)\n\t-b - use binary transfer mode\n\t-c cmd - issue arbitrary command (remote is used as a parameter if provided) \n\t-d - list directory details using MLSD (remote is used as the pathname if provided)\n\t-e - use EPSV with IPv4 (default false)\n\t-E - encoding to use for control channel\n\t-f - issue FEAT command (remote and local files are ignored)\n\t-h - list hidden files (applies to -l and -n only)\n\t-k secs - use keep-alive timer (setControlKeepAliveTimeout)\n\t-l - list files using LIST (remote is used as the pathname if provided)\n\t Files are listed twice: first in raw mode, then as the formatted parsed data.\n\t N.B. if the wrong server-type is used, output may be lost. Use -U or -S as necessary.\n\t-L - use lenient future dates (server dates may be up to 1 day into future)\n\t-m - list file details using MDTM (remote is used as the pathname if provided)\n\t-n - list file names using NLST (remote is used as the pathname if provided)\n\t-p true|false|protocol[,true|false] - use FTPSClient with the specified protocol and/or isImplicit setting\n\t-s - store file on server (upload)\n\t-S - systemType set server system type (e.g. UNIX VMS WINDOWS)\n\t-t - list file details using MLST (remote is used as the pathname if provided)\n\t-U - save unparseable responses\n\t-w msec - wait time for keep-alive reply (setControlKeepAliveReplyTimeout)\n\t-T all|valid|none - use one of the built-in TrustManager implementations (none = JVM default)\n\t-y format - set default date format string\n\t-Y format - set recent date format string\n\t-Z timezone - set the server timezone for parsing LIST responses\n\t-z timezone - set the timezone for displaying MDTM, LIST, MLSD, MLST responses\n\t-PrH server[:port] - HTTP Proxy host and optional port[80] \n\t-PrU user - HTTP Proxy server username\n\t-PrP password - HTTP Proxy server password\n\t-# - add hash display during transfers\n");
|
||||
System.exit(1);
|
||||
}
|
||||
String server = args[base++];
|
||||
int port = 0;
|
||||
String[] parts = server.split(":");
|
||||
if (parts.length == 2) {
|
||||
server = parts[0];
|
||||
port = Integer.parseInt(parts[1]);
|
||||
}
|
||||
if (username == null) {
|
||||
username = args[base++];
|
||||
password = args[base++];
|
||||
}
|
||||
String remote = null;
|
||||
if (args.length - base > 0)
|
||||
remote = args[base++];
|
||||
String local = null;
|
||||
if (args.length - base > 0)
|
||||
local = args[base++];
|
||||
if (protocol == null) {
|
||||
if (proxyHost != null) {
|
||||
System.out.println("Using HTTP proxy server: " + proxyHost);
|
||||
FTPHTTPClient fTPHTTPClient = new FTPHTTPClient(proxyHost, proxyPort, proxyUser, proxyPassword);
|
||||
} else {
|
||||
FTPClient ftp = new FTPClient();
|
||||
}
|
||||
} else {
|
||||
FTPSClient ftps;
|
||||
if (protocol.equals("true")) {
|
||||
ftps = new FTPSClient(true);
|
||||
} else if (protocol.equals("false")) {
|
||||
ftps = new FTPSClient(false);
|
||||
} else {
|
||||
String[] prot = protocol.split(",");
|
||||
if (prot.length == 1) {
|
||||
ftps = new FTPSClient(protocol);
|
||||
} else {
|
||||
ftps = new FTPSClient(prot[0], Boolean.parseBoolean(prot[1]));
|
||||
}
|
||||
}
|
||||
fTPSClient = ftps;
|
||||
if ("all".equals(trustmgr)) {
|
||||
ftps.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());
|
||||
} else if ("valid".equals(trustmgr)) {
|
||||
ftps.setTrustManager(TrustManagerUtils.getValidateServerCertificateTrustManager());
|
||||
} else if ("none".equals(trustmgr)) {
|
||||
ftps.setTrustManager(null);
|
||||
}
|
||||
}
|
||||
if (printHash)
|
||||
fTPSClient.setCopyStreamListener(createListener());
|
||||
if (keepAliveTimeout >= 0L)
|
||||
fTPSClient.setControlKeepAliveTimeout(keepAliveTimeout);
|
||||
if (controlKeepAliveReplyTimeout >= 0)
|
||||
fTPSClient.setControlKeepAliveReplyTimeout(controlKeepAliveReplyTimeout);
|
||||
if (encoding != null)
|
||||
fTPSClient.setControlEncoding(encoding);
|
||||
fTPSClient.setListHiddenFiles(hidden);
|
||||
fTPSClient.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
if (serverType != null) {
|
||||
config = new FTPClientConfig(serverType);
|
||||
} else {
|
||||
config = new FTPClientConfig();
|
||||
}
|
||||
config.setUnparseableEntries(saveUnparseable);
|
||||
if (defaultDateFormat != null)
|
||||
config.setDefaultDateFormatStr(defaultDateFormat);
|
||||
if (recentDateFormat != null)
|
||||
config.setRecentDateFormatStr(recentDateFormat);
|
||||
fTPSClient.configure(config);
|
||||
try {
|
||||
if (port > 0) {
|
||||
fTPSClient.connect(server, port);
|
||||
} else {
|
||||
fTPSClient.connect(server);
|
||||
}
|
||||
System.out.println("Connected to " + server + " on " + ((port > 0) ? port : fTPSClient.getDefaultPort()));
|
||||
int reply = fTPSClient.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
fTPSClient.disconnect();
|
||||
System.err.println("FTP server refused connection.");
|
||||
System.exit(1);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (fTPSClient.isConnected())
|
||||
try {
|
||||
fTPSClient.disconnect();
|
||||
} catch (IOException f) {}
|
||||
System.err.println("Could not connect to server.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
//try {
|
||||
|
||||
//} catch (FTPConnectionClosedException e) {
|
||||
//error = true;
|
||||
//System.err.println("Server closed connection.");
|
||||
//e.printStackTrace();
|
||||
//} catch (IOException e) {
|
||||
//error = true;
|
||||
//e.printStackTrace();
|
||||
//} finally {
|
||||
//if (fTPSClient.isConnected())
|
||||
//try {
|
||||
//fTPSClient.disconnect();
|
||||
//} catch (IOException f) {}
|
||||
//}
|
||||
//System.exit(error ? 1 : 0);
|
||||
}
|
||||
|
||||
private static CopyStreamListener createListener() {
|
||||
return new CopyStreamListener() {
|
||||
private long megsTotal = 0L;
|
||||
|
||||
public void bytesTransferred(CopyStreamEvent event) {
|
||||
bytesTransferred(event.getTotalBytesTransferred(), event.getBytesTransferred(), event.getStreamSize());
|
||||
}
|
||||
|
||||
public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) {
|
||||
long megs = totalBytesTransferred / 1000000L;
|
||||
long l;
|
||||
for (l = this.megsTotal; l < megs; l++)
|
||||
System.err.print("#");
|
||||
this.megsTotal = megs;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\ftp\FTPClientExample.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,110 @@
|
||||
package examples.ftp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
|
||||
public final class ServerToServerFTP {
|
||||
public static void main(String[] args) {
|
||||
int port1 = 0, port2 = 0;
|
||||
if (args.length < 8) {
|
||||
System.err.println("Usage: ftp <host1> <user1> <pass1> <file1> <host2> <user2> <pass2> <file2>");
|
||||
System.exit(1);
|
||||
}
|
||||
String server1 = args[0];
|
||||
String[] parts = server1.split(":");
|
||||
if (parts.length == 2) {
|
||||
server1 = parts[0];
|
||||
port1 = Integer.parseInt(parts[1]);
|
||||
}
|
||||
String username1 = args[1];
|
||||
String password1 = args[2];
|
||||
String file1 = args[3];
|
||||
String server2 = args[4];
|
||||
parts = server2.split(":");
|
||||
if (parts.length == 2) {
|
||||
server2 = parts[0];
|
||||
port2 = Integer.parseInt(parts[1]);
|
||||
}
|
||||
String username2 = args[5];
|
||||
String password2 = args[6];
|
||||
String file2 = args[7];
|
||||
PrintCommandListener printCommandListener = new PrintCommandListener(new PrintWriter(System.out), true);
|
||||
FTPClient ftp1 = new FTPClient();
|
||||
ftp1.addProtocolCommandListener((ProtocolCommandListener)printCommandListener);
|
||||
FTPClient ftp2 = new FTPClient();
|
||||
ftp2.addProtocolCommandListener((ProtocolCommandListener)printCommandListener);
|
||||
try {
|
||||
if (port1 > 0) {
|
||||
ftp1.connect(server1, port1);
|
||||
} else {
|
||||
ftp1.connect(server1);
|
||||
}
|
||||
System.out.println("Connected to " + server1 + ".");
|
||||
int reply = ftp1.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
ftp1.disconnect();
|
||||
System.err.println("FTP server1 refused connection.");
|
||||
System.exit(1);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (ftp1.isConnected())
|
||||
try {
|
||||
ftp1.disconnect();
|
||||
} catch (IOException f) {}
|
||||
System.err.println("Could not connect to server1.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
if (port2 > 0) {
|
||||
ftp2.connect(server2, port2);
|
||||
} else {
|
||||
ftp2.connect(server2);
|
||||
}
|
||||
System.out.println("Connected to " + server2 + ".");
|
||||
int reply = ftp2.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
ftp2.disconnect();
|
||||
System.err.println("FTP server2 refused connection.");
|
||||
System.exit(1);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (ftp2.isConnected())
|
||||
try {
|
||||
ftp2.disconnect();
|
||||
} catch (IOException f) {}
|
||||
System.err.println("Could not connect to server2.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
//try {
|
||||
|
||||
//} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
//System.exit(1);
|
||||
//} finally {
|
||||
//try {
|
||||
//if (ftp1.isConnected()) {
|
||||
//ftp1.logout();
|
||||
//ftp1.disconnect();
|
||||
//}
|
||||
//} catch (IOException e) {}
|
||||
//try {
|
||||
//if (ftp2.isConnected()) {
|
||||
//ftp2.logout();
|
||||
//ftp2.disconnect();
|
||||
//}
|
||||
//} catch (IOException e) {}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\ftp\ServerToServerFTP.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,179 @@
|
||||
package examples.ftp;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import org.apache.commons.net.tftp.TFTPClient;
|
||||
import org.apache.commons.net.tftp.TFTPPacket;
|
||||
|
||||
public final class TFTPExample {
|
||||
static final String USAGE = "Usage: tftp [options] hostname localfile remotefile\n\nhostname - The name of the remote host [:port]\nlocalfile - The name of the local file to send or the name to use for\n\tthe received file\nremotefile - The name of the remote file to receive or the name for\n\tthe remote server to use to name the local file being sent.\n\noptions: (The default is to assume -r -b)\n\t-t timeout in seconds (default 60s)\n\t-s Send a local file\n\t-r Receive a remote file\n\t-a Use ASCII transfer mode\n\t-b Use binary transfer mode\n\t-v Verbose (trace packets)\n";
|
||||
|
||||
public static void main(String[] args) {
|
||||
TFTPClient tftp;
|
||||
boolean receiveFile = true;
|
||||
int transferMode = 1;
|
||||
int timeout = 60000;
|
||||
boolean verbose = false;
|
||||
int argc;
|
||||
for (argc = 0; argc < args.length; ) {
|
||||
String arg = args[argc];
|
||||
if (arg.startsWith("-")) {
|
||||
if (arg.equals("-r")) {
|
||||
receiveFile = true;
|
||||
} else if (arg.equals("-s")) {
|
||||
receiveFile = false;
|
||||
} else if (arg.equals("-a")) {
|
||||
transferMode = 0;
|
||||
} else if (arg.equals("-b")) {
|
||||
transferMode = 1;
|
||||
} else if (arg.equals("-t")) {
|
||||
timeout = 1000 * Integer.parseInt(args[++argc]);
|
||||
} else if (arg.equals("-v")) {
|
||||
verbose = true;
|
||||
} else {
|
||||
System.err.println("\007Error: unrecognized option.");
|
||||
System.err.print("Usage: tftp [options] hostname localfile remotefile\n\nhostname - The name of the remote host [:port]\nlocalfile - The name of the local file to send or the name to use for\n\tthe received file\nremotefile - The name of the remote file to receive or the name for\n\tthe remote server to use to name the local file being sent.\n\noptions: (The default is to assume -r -b)\n\t-t timeout in seconds (default 60s)\n\t-s Send a local file\n\t-r Receive a remote file\n\t-a Use ASCII transfer mode\n\t-b Use binary transfer mode\n\t-v Verbose (trace packets)\n");
|
||||
System.exit(1);
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
}
|
||||
if (args.length - argc != 3) {
|
||||
System.err.println("\007Error: invalid number of arguments.");
|
||||
System.err.print("Usage: tftp [options] hostname localfile remotefile\n\nhostname - The name of the remote host [:port]\nlocalfile - The name of the local file to send or the name to use for\n\tthe received file\nremotefile - The name of the remote file to receive or the name for\n\tthe remote server to use to name the local file being sent.\n\noptions: (The default is to assume -r -b)\n\t-t timeout in seconds (default 60s)\n\t-s Send a local file\n\t-r Receive a remote file\n\t-a Use ASCII transfer mode\n\t-b Use binary transfer mode\n\t-v Verbose (trace packets)\n");
|
||||
System.exit(1);
|
||||
}
|
||||
String hostname = args[argc];
|
||||
String localFilename = args[argc + 1];
|
||||
String remoteFilename = args[argc + 2];
|
||||
if (verbose) {
|
||||
tftp = new TFTPClient() {
|
||||
protected void trace(String direction, TFTPPacket packet) {
|
||||
System.out.println(direction + " " + packet);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
tftp = new TFTPClient();
|
||||
}
|
||||
tftp.setDefaultTimeout(timeout);
|
||||
boolean closed = false;
|
||||
if (receiveFile) {
|
||||
closed = receive(transferMode, hostname, localFilename, remoteFilename, tftp);
|
||||
} else {
|
||||
closed = send(transferMode, hostname, localFilename, remoteFilename, tftp);
|
||||
}
|
||||
System.out.println("Recd: " + tftp.getTotalBytesReceived() + " Sent: " + tftp.getTotalBytesSent());
|
||||
if (!closed) {
|
||||
System.out.println("Failed");
|
||||
System.exit(1);
|
||||
}
|
||||
System.out.println("OK");
|
||||
}
|
||||
|
||||
private static boolean send(int transferMode, String hostname, String localFilename, String remoteFilename, TFTPClient tftp) {
|
||||
boolean bool;
|
||||
FileInputStream input = null;
|
||||
try {
|
||||
input = new FileInputStream(localFilename);
|
||||
} catch (IOException e) {
|
||||
tftp.close();
|
||||
System.err.println("Error: could not open local file for reading.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
open(tftp);
|
||||
try {
|
||||
String[] parts = hostname.split(":");
|
||||
if (parts.length == 2) {
|
||||
tftp.sendFile(remoteFilename, transferMode, input, parts[0], Integer.parseInt(parts[1]));
|
||||
} else {
|
||||
tftp.sendFile(remoteFilename, transferMode, input, hostname);
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Error: could not resolve hostname.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error: I/O exception occurred while sending file.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
} finally {
|
||||
bool = close(tftp, input);
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
|
||||
private static boolean receive(int transferMode, String hostname, String localFilename, String remoteFilename, TFTPClient tftp) {
|
||||
boolean bool;
|
||||
FileOutputStream output = null;
|
||||
File file = new File(localFilename);
|
||||
if (file.exists()) {
|
||||
System.err.println("Error: " + localFilename + " already exists.");
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
output = new FileOutputStream(file);
|
||||
} catch (IOException e) {
|
||||
tftp.close();
|
||||
System.err.println("Error: could not open local file for writing.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
open(tftp);
|
||||
try {
|
||||
String[] parts = hostname.split(":");
|
||||
if (parts.length == 2) {
|
||||
tftp.receiveFile(remoteFilename, transferMode, output, parts[0], Integer.parseInt(parts[1]));
|
||||
} else {
|
||||
tftp.receiveFile(remoteFilename, transferMode, output, hostname);
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Error: could not resolve hostname.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error: I/O exception occurred while receiving file.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
} finally {
|
||||
bool = close(tftp, output);
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
|
||||
private static boolean close(TFTPClient tftp, Closeable output) {
|
||||
boolean bool;
|
||||
tftp.close();
|
||||
try {
|
||||
if (output != null)
|
||||
output.close();
|
||||
bool = true;
|
||||
} catch (IOException e) {
|
||||
bool = false;
|
||||
System.err.println("Error: error closing file.");
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
|
||||
private static void open(TFTPClient tftp) {
|
||||
try {
|
||||
tftp.open();
|
||||
} catch (SocketException e) {
|
||||
System.err.println("Error: could not open local UDP socket.");
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\ftp\TFTPExample.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,350 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandEvent;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.imap.IMAP;
|
||||
import org.apache.commons.net.imap.IMAPClient;
|
||||
|
||||
public final class IMAPExportMbox {
|
||||
private static final String CRLF = "\r\n";
|
||||
|
||||
private static final String LF = "\n";
|
||||
|
||||
private static final String EOL_DEFAULT = System.getProperty("line.separator");
|
||||
|
||||
private static final Pattern PATFROM = Pattern.compile(">*From ");
|
||||
|
||||
private static final Pattern PATID = Pattern.compile(".*INTERNALDATE \"(\\d\\d-\\w{3}-\\d{4} \\d\\d:\\d\\d:\\d\\d [+-]\\d+)\"");
|
||||
|
||||
private static final int PATID_DATE_GROUP = 1;
|
||||
|
||||
private static final Pattern PATSEQ = Pattern.compile("\\* (\\d+) ");
|
||||
|
||||
private static final int PATSEQ_SEQUENCE_GROUP = 1;
|
||||
|
||||
private static final Pattern PATEXISTS = Pattern.compile("\\* (\\d+) EXISTS");
|
||||
|
||||
private static final Pattern PATTEMPFAIL = Pattern.compile("[A-Z]{4} NO \\[TEMPFAIL\\] FETCH .*");
|
||||
|
||||
private static final int CONNECT_TIMEOUT = 10;
|
||||
|
||||
private static final int READ_TIMEOUT = 10;
|
||||
|
||||
public static void main(String[] args) throws IOException, URISyntaxException {
|
||||
URI uRI;
|
||||
String itemNames;
|
||||
MboxListener chunkListener;
|
||||
int connect_timeout = 10;
|
||||
int read_timeout = 10;
|
||||
int argIdx = 0;
|
||||
String eol = EOL_DEFAULT;
|
||||
boolean printHash = false;
|
||||
boolean printMarker = false;
|
||||
int retryWaitSecs = 0;
|
||||
for (argIdx = 0; argIdx < args.length; argIdx++) {
|
||||
if (args[argIdx].equals("-c")) {
|
||||
connect_timeout = Integer.parseInt(args[++argIdx]);
|
||||
} else if (args[argIdx].equals("-r")) {
|
||||
read_timeout = Integer.parseInt(args[++argIdx]);
|
||||
} else if (args[argIdx].equals("-R")) {
|
||||
retryWaitSecs = Integer.parseInt(args[++argIdx]);
|
||||
} else if (args[argIdx].equals("-LF")) {
|
||||
eol = "\n";
|
||||
} else if (args[argIdx].equals("-CRLF")) {
|
||||
eol = "\r\n";
|
||||
} else if (args[argIdx].equals("-.")) {
|
||||
printHash = true;
|
||||
} else if (args[argIdx].equals("-X")) {
|
||||
printMarker = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int argCount = args.length - argIdx;
|
||||
if (argCount < 2) {
|
||||
System.err.println("Usage: IMAPExportMbox [-LF|-CRLF] [-c n] [-r n] [-R n] [-.] [-X] imap[s]://user:password@host[:port]/folder/path [+|-]<mboxfile> [sequence-set] [itemnames]");
|
||||
System.err.println("\t-LF | -CRLF set end-of-line to LF or CRLF (default is the line.separator system property)");
|
||||
System.err.println("\t-c connect timeout in seconds (default 10)");
|
||||
System.err.println("\t-r read timeout in seconds (default 10)");
|
||||
System.err.println("\t-R temporary failure retry wait in seconds (default 0; i.e. disabled)");
|
||||
System.err.println("\t-. print a . for each complete message received");
|
||||
System.err.println("\t-X print the X-IMAP line for each complete message received");
|
||||
System.err.println("\tthe mboxfile is where the messages are stored; use '-' to write to standard output.");
|
||||
System.err.println("\tPrefix filename with '+' to append to the file. Prefix with '-' to allow overwrite.");
|
||||
System.err.println("\ta sequence-set is a list of numbers/number ranges e.g. 1,2,3-10,20:* - default 1:*");
|
||||
System.err.println("\titemnames are the message data item name(s) e.g. BODY.PEEK[HEADER.FIELDS (SUBJECT)] or a macro e.g. ALL - default (INTERNALDATE BODY.PEEK[])");
|
||||
System.exit(1);
|
||||
}
|
||||
String uriString = args[argIdx++];
|
||||
try {
|
||||
uRI = URI.create(uriString);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Matcher m = Pattern.compile("(imaps?://[^/]+)(/.*)").matcher(uriString);
|
||||
if (m.matches()) {
|
||||
uRI = URI.create(m.group(1));
|
||||
uRI = new URI(uRI.getScheme(), uRI.getAuthority(), m.group(2), null, null);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
String file = args[argIdx++];
|
||||
String sequenceSet = (argCount > 2) ? args[argIdx++] : "1:*";
|
||||
if (argCount > 3) {
|
||||
if (argCount > 4) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("(");
|
||||
for (int i = 4; i <= argCount; i++) {
|
||||
if (i > 4)
|
||||
sb.append(" ");
|
||||
sb.append(args[argIdx++]);
|
||||
}
|
||||
sb.append(")");
|
||||
itemNames = sb.toString();
|
||||
} else {
|
||||
itemNames = args[argIdx++];
|
||||
}
|
||||
} else {
|
||||
itemNames = "(INTERNALDATE BODY.PEEK[])";
|
||||
}
|
||||
boolean checkSequence = sequenceSet.matches("\\d+:(\\d+|\\*)");
|
||||
if (file.equals("-")) {
|
||||
chunkListener = null;
|
||||
} else if (file.startsWith("+")) {
|
||||
File mbox = new File(file.substring(1));
|
||||
System.out.println("Appending to file " + mbox);
|
||||
chunkListener = new MboxListener(new BufferedWriter(new FileWriter(mbox, true)), eol, printHash, printMarker, checkSequence);
|
||||
} else if (file.startsWith("-")) {
|
||||
File mbox = new File(file.substring(1));
|
||||
System.out.println("Writing to file " + mbox);
|
||||
chunkListener = new MboxListener(new BufferedWriter(new FileWriter(mbox, false)), eol, printHash, printMarker, checkSequence);
|
||||
} else {
|
||||
File mbox = new File(file);
|
||||
if (mbox.exists() && mbox.length() > 0L)
|
||||
throw new IOException("mailbox file: " + mbox + " already exists and is non-empty!");
|
||||
System.out.println("Creating file " + mbox);
|
||||
chunkListener = new MboxListener(new BufferedWriter(new FileWriter(mbox)), eol, printHash, printMarker, checkSequence);
|
||||
}
|
||||
String path = uRI.getPath();
|
||||
if (path == null || path.length() < 1)
|
||||
throw new IllegalArgumentException("Invalid folderPath: '" + path + "'");
|
||||
String folder = path.substring(1);
|
||||
PrintCommandListener listener = new PrintCommandListener(System.out, true) {
|
||||
public void protocolReplyReceived(ProtocolCommandEvent event) {
|
||||
if (event.getReplyCode() != 3)
|
||||
super.protocolReplyReceived(event);
|
||||
}
|
||||
};
|
||||
IMAPClient imap = IMAPUtils.imapLogin(uRI, connect_timeout * 1000, (ProtocolCommandListener)listener);
|
||||
String maxIndexInFolder = null;
|
||||
try {
|
||||
imap.setSoTimeout(read_timeout * 1000);
|
||||
if (!imap.select(folder))
|
||||
throw new IOException("Could not select folder: " + folder);
|
||||
for (String line : imap.getReplyStrings()) {
|
||||
maxIndexInFolder = matches(line, PATEXISTS, 1);
|
||||
if (maxIndexInFolder != null)
|
||||
break;
|
||||
}
|
||||
if (chunkListener != null)
|
||||
imap.setChunkListener(chunkListener);
|
||||
while (true) {
|
||||
boolean ok = imap.fetch(sequenceSet, itemNames);
|
||||
if (!ok && retryWaitSecs > 0 && chunkListener != null && checkSequence) {
|
||||
String replyString = imap.getReplyString();
|
||||
if (startsWith(replyString, PATTEMPFAIL)) {
|
||||
System.err.println("Temporary error detected, will retry in " + retryWaitSecs + "seconds");
|
||||
sequenceSet = (chunkListener.lastSeq + 1L) + ":*";
|
||||
try {
|
||||
Thread.sleep((retryWaitSecs * 1000));
|
||||
} catch (InterruptedException e) {}
|
||||
continue;
|
||||
}
|
||||
throw new IOException("FETCH " + sequenceSet + " " + itemNames + " failed with " + replyString);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
String count = (chunkListener == null) ? "?" : Integer.toString(chunkListener.total);
|
||||
System.err.println("FETCH " + sequenceSet + " " + itemNames + " failed after processing " + count + " complete messages ");
|
||||
if (chunkListener != null)
|
||||
System.err.println("Last complete response seen: " + chunkListener.lastFetched);
|
||||
throw ioe;
|
||||
} finally {
|
||||
if (printHash)
|
||||
System.err.println();
|
||||
if (chunkListener != null) {
|
||||
chunkListener.close();
|
||||
Iterator<String> missingIds = chunkListener.missingIds.iterator();
|
||||
if (missingIds.hasNext()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
sb.append(missingIds.next());
|
||||
if (!missingIds.hasNext())
|
||||
break;
|
||||
sb.append(",");
|
||||
}
|
||||
System.err.println("*** Missing ids: " + sb.toString());
|
||||
}
|
||||
}
|
||||
imap.logout();
|
||||
imap.disconnect();
|
||||
}
|
||||
if (chunkListener != null)
|
||||
System.out.println("Processed " + chunkListener.total + " messages.");
|
||||
if (maxIndexInFolder != null)
|
||||
System.out.println("Folder contained " + maxIndexInFolder + " messages.");
|
||||
}
|
||||
|
||||
private static boolean startsWith(String input, Pattern pat) {
|
||||
Matcher m = pat.matcher(input);
|
||||
return m.lookingAt();
|
||||
}
|
||||
|
||||
private static String matches(String input, Pattern pat, int index) {
|
||||
Matcher m = pat.matcher(input);
|
||||
if (m.lookingAt())
|
||||
return m.group(index);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class MboxListener implements IMAP.IMAPChunkListener {
|
||||
private final BufferedWriter bw;
|
||||
|
||||
volatile int total = 0;
|
||||
|
||||
volatile String lastFetched;
|
||||
|
||||
volatile List<String> missingIds = new ArrayList<String>();
|
||||
|
||||
volatile long lastSeq = -1L;
|
||||
|
||||
private final String eol;
|
||||
|
||||
private final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd HH:mm:ss YYYY");
|
||||
|
||||
private final SimpleDateFormat IDPARSE = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z");
|
||||
|
||||
private final boolean printHash;
|
||||
|
||||
private final boolean printMarker;
|
||||
|
||||
private final boolean checkSequence;
|
||||
|
||||
MboxListener(BufferedWriter bw, String eol, boolean printHash, boolean printMarker, boolean checkSequence) throws IOException {
|
||||
this.eol = eol;
|
||||
this.printHash = printHash;
|
||||
this.printMarker = printMarker;
|
||||
this.DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
this.bw = bw;
|
||||
this.checkSequence = checkSequence;
|
||||
}
|
||||
|
||||
public boolean chunkReceived(IMAP imap) {
|
||||
String[] replyStrings = imap.getReplyStrings();
|
||||
Date received = new Date();
|
||||
String firstLine = replyStrings[0];
|
||||
Matcher m = IMAPExportMbox.PATID.matcher(firstLine);
|
||||
if (m.lookingAt()) {
|
||||
String date = m.group(1);
|
||||
try {
|
||||
received = this.IDPARSE.parse(date);
|
||||
} catch (ParseException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
} else {
|
||||
System.err.println("No timestamp found in: " + firstLine + " - using current time");
|
||||
}
|
||||
String replyTo = "MAILER-DAEMON";
|
||||
int i;
|
||||
for (i = 1; i < replyStrings.length - 1; i++) {
|
||||
String line = replyStrings[i];
|
||||
if (line.startsWith("Return-Path: ")) {
|
||||
String[] parts = line.split(" ", 2);
|
||||
replyTo = parts[1];
|
||||
if (replyTo.startsWith("<")) {
|
||||
replyTo = replyTo.substring(1, replyTo.length() - 1);
|
||||
break;
|
||||
}
|
||||
System.err.println("Unexpected Return-path:" + line + " in " + firstLine);
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.bw.append("From ");
|
||||
this.bw.append(replyTo);
|
||||
this.bw.append(' ');
|
||||
this.bw.append(this.DATE_FORMAT.format(received));
|
||||
this.bw.append(this.eol);
|
||||
this.bw.append("X-IMAP-Response: ").append(firstLine).append(this.eol);
|
||||
if (this.printMarker)
|
||||
System.err.println("[" + this.total + "] " + firstLine);
|
||||
for (i = 1; i < replyStrings.length - 1; i++) {
|
||||
String line = replyStrings[i];
|
||||
if (IMAPExportMbox.startsWith(line, IMAPExportMbox.PATFROM))
|
||||
this.bw.append('>');
|
||||
this.bw.append(line);
|
||||
this.bw.append(this.eol);
|
||||
}
|
||||
String lastLine = replyStrings[replyStrings.length - 1];
|
||||
int lastLength = lastLine.length();
|
||||
if (lastLength > 1) {
|
||||
this.bw.append(lastLine, 0, lastLength - 1);
|
||||
this.bw.append(this.eol);
|
||||
}
|
||||
this.bw.append(this.eol);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.lastFetched = firstLine;
|
||||
this.total++;
|
||||
if (this.checkSequence) {
|
||||
m = IMAPExportMbox.PATSEQ.matcher(firstLine);
|
||||
if (m.lookingAt()) {
|
||||
long msgSeq = Long.parseLong(m.group(1));
|
||||
if (this.lastSeq != -1L) {
|
||||
long missing = msgSeq - this.lastSeq - 1L;
|
||||
if (missing != 0L) {
|
||||
long j;
|
||||
for (j = this.lastSeq + 1L; j < msgSeq; j++)
|
||||
this.missingIds.add(String.valueOf(j));
|
||||
System.err.println("*** Sequence error: current=" + msgSeq + " previous=" + this.lastSeq + " Missing=" + missing);
|
||||
}
|
||||
}
|
||||
this.lastSeq = msgSeq;
|
||||
}
|
||||
}
|
||||
if (this.printHash)
|
||||
System.err.print(".");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (this.bw != null)
|
||||
this.bw.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\IMAPExportMbox.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,129 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.net.imap.IMAPClient;
|
||||
|
||||
public final class IMAPImportMbox {
|
||||
private static final String CRLF = "\r\n";
|
||||
|
||||
private static final Pattern PATFROM = Pattern.compile(">+From ");
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length < 2) {
|
||||
System.err.println("Usage: IMAPImportMbox imap[s]://user:password@host[:port]/folder/path <mboxfile> [selectors]");
|
||||
System.err.println("\tWhere: a selector is a list of numbers/number ranges - 1,2,3-10 - or a list of strings to match in the initial From line");
|
||||
System.exit(1);
|
||||
}
|
||||
URI uri = URI.create(args[0]);
|
||||
String file = args[1];
|
||||
File mbox = new File(file);
|
||||
if (!mbox.isFile() || !mbox.canRead())
|
||||
throw new IOException("Cannot read mailbox file: " + mbox);
|
||||
String path = uri.getPath();
|
||||
if (path == null || path.length() < 1)
|
||||
throw new IllegalArgumentException("Invalid folderPath: '" + path + "'");
|
||||
String folder = path.substring(1);
|
||||
List<String> contains = new ArrayList<String>();
|
||||
BitSet msgNums = new BitSet();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.matches("\\d+(-\\d+)?(,\\d+(-\\d+)?)*")) {
|
||||
for (String entry : arg.split(",")) {
|
||||
String[] parts = entry.split("-");
|
||||
if (parts.length == 2) {
|
||||
int low = Integer.parseInt(parts[0]);
|
||||
int high = Integer.parseInt(parts[1]);
|
||||
for (int j = low; j <= high; j++)
|
||||
msgNums.set(j);
|
||||
} else {
|
||||
msgNums.set(Integer.parseInt(entry));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
contains.add(arg);
|
||||
}
|
||||
}
|
||||
IMAPClient imap = IMAPUtils.imapLogin(uri, 10000, null);
|
||||
int total = 0;
|
||||
int loaded = 0;
|
||||
try {
|
||||
imap.setSoTimeout(6000);
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean wanted = false;
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.startsWith("From ")) {
|
||||
if (process(sb, imap, folder, total))
|
||||
loaded++;
|
||||
sb.setLength(0);
|
||||
total++;
|
||||
wanted = wanted(total, line, msgNums, contains);
|
||||
} else if (startsWith(line, PATFROM)) {
|
||||
line = line.substring(1);
|
||||
}
|
||||
if (wanted) {
|
||||
sb.append(line);
|
||||
sb.append("\r\n");
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
if (wanted && process(sb, imap, folder, total))
|
||||
loaded++;
|
||||
} catch (IOException e) {
|
||||
System.out.println(imap.getReplyString());
|
||||
e.printStackTrace();
|
||||
System.exit(10);
|
||||
return;
|
||||
} finally {
|
||||
imap.logout();
|
||||
imap.disconnect();
|
||||
}
|
||||
System.out.println("Processed " + total + " messages, loaded " + loaded);
|
||||
}
|
||||
|
||||
private static boolean startsWith(String input, Pattern pat) {
|
||||
Matcher m = pat.matcher(input);
|
||||
return m.lookingAt();
|
||||
}
|
||||
|
||||
private static boolean process(StringBuilder sb, IMAPClient imap, String folder, int msgNum) throws IOException {
|
||||
int length = sb.length();
|
||||
boolean haveMessage = (length > 2);
|
||||
if (haveMessage) {
|
||||
System.out.println("MsgNum: " + msgNum + " Length " + length);
|
||||
sb.setLength(length - 2);
|
||||
String msg = sb.toString();
|
||||
if (!imap.append(folder, null, null, msg))
|
||||
throw new IOException("Failed to import message: " + msgNum + " " + imap.getReplyString());
|
||||
}
|
||||
return haveMessage;
|
||||
}
|
||||
|
||||
private static boolean wanted(int msgNum, String line, BitSet msgNums, List<String> contains) {
|
||||
return ((msgNums.isEmpty() && contains.isEmpty()) || msgNums.get(msgNum) || listContains(contains, line));
|
||||
}
|
||||
|
||||
private static boolean listContains(List<String> contains, String string) {
|
||||
for (String entry : contains) {
|
||||
if (string.contains(entry))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\IMAPImportMbox.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,41 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.imap.IMAPClient;
|
||||
|
||||
public final class IMAPMail {
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length != 1) {
|
||||
System.err.println("Usage: IMAPMail imap[s]://username:password@server/");
|
||||
System.err.println("Connects to server; lists capabilities and shows Inbox status");
|
||||
System.exit(1);
|
||||
}
|
||||
URI uri = URI.create(args[0]);
|
||||
IMAPClient imap = IMAPUtils.imapLogin(uri, 10000, null);
|
||||
imap.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(System.out, true));
|
||||
try {
|
||||
imap.setSoTimeout(6000);
|
||||
imap.capability();
|
||||
imap.select("inbox");
|
||||
imap.examine("inbox");
|
||||
imap.status("inbox", new String[] { "MESSAGES" });
|
||||
} catch (IOException e) {
|
||||
System.out.println(imap.getReplyString());
|
||||
e.printStackTrace();
|
||||
System.exit(10);
|
||||
return;
|
||||
} finally {
|
||||
imap.logout();
|
||||
imap.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\IMAPMail.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,56 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.imap.IMAPClient;
|
||||
import org.apache.commons.net.imap.IMAPSClient;
|
||||
|
||||
class IMAPUtils {
|
||||
static IMAPClient imapLogin(URI uri, int defaultTimeout, ProtocolCommandListener listener) throws IOException {
|
||||
IMAPClient imap = null;
|
||||
String userInfo = uri.getUserInfo();
|
||||
if (userInfo == null)
|
||||
throw new IllegalArgumentException("Missing userInfo details");
|
||||
String[] userpass = userInfo.split(":");
|
||||
if (userpass.length != 2)
|
||||
throw new IllegalArgumentException("Invalid userInfo details: '" + userInfo + "'");
|
||||
String username = userpass[0];
|
||||
String password = userpass[1];
|
||||
password = Utils.getPassword(username, password);
|
||||
String scheme = uri.getScheme();
|
||||
if ("imaps".equalsIgnoreCase(scheme)) {
|
||||
System.out.println("Using secure protocol");
|
||||
IMAPSClient iMAPSClient = new IMAPSClient(true);
|
||||
} else if ("imap".equalsIgnoreCase(scheme)) {
|
||||
imap = new IMAPClient();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid protocol: " + scheme);
|
||||
}
|
||||
int port = uri.getPort();
|
||||
if (port != -1)
|
||||
imap.setDefaultPort(port);
|
||||
imap.setDefaultTimeout(defaultTimeout);
|
||||
if (listener != null)
|
||||
imap.addProtocolCommandListener(listener);
|
||||
String server = uri.getHost();
|
||||
System.out.println("Connecting to server " + server + " on " + imap.getDefaultPort());
|
||||
try {
|
||||
imap.connect(server);
|
||||
System.out.println("Successfully connected");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not connect to server.", e);
|
||||
}
|
||||
if (!imap.login(username, password)) {
|
||||
imap.disconnect();
|
||||
throw new RuntimeException("Could not login to server. Check login details.");
|
||||
}
|
||||
return imap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\IMAPUtils.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,121 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.pop3.POP3Client;
|
||||
import org.apache.commons.net.pop3.POP3MessageInfo;
|
||||
import org.apache.commons.net.pop3.POP3SClient;
|
||||
|
||||
public final class POP3Mail {
|
||||
public static final void printMessageInfo(BufferedReader reader, int id) throws IOException {
|
||||
String from = "";
|
||||
String subject = "";
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String lower = line.toLowerCase(Locale.ENGLISH);
|
||||
if (lower.startsWith("from: ")) {
|
||||
from = line.substring(6).trim();
|
||||
continue;
|
||||
}
|
||||
if (lower.startsWith("subject: "))
|
||||
subject = line.substring(9).trim();
|
||||
}
|
||||
System.out.println(Integer.toString(id) + " From: " + from + " Subject: " + subject);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
POP3Client pop3 = null;
|
||||
int port;
|
||||
if (args.length < 3) {
|
||||
System.err.println("Usage: POP3Mail <server[:port]> <username> <password|-|*|VARNAME> [TLS [true=implicit]]");
|
||||
System.exit(1);
|
||||
}
|
||||
String[] arg0 = args[0].split(":");
|
||||
String server = arg0[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
try {
|
||||
password = Utils.getPassword(username, password);
|
||||
} catch (IOException e1) {
|
||||
System.err.println("Could not retrieve password: " + e1.getMessage());
|
||||
return;
|
||||
}
|
||||
String proto = (args.length > 3) ? args[3] : null;
|
||||
boolean implicit = (args.length > 4) ? Boolean.parseBoolean(args[4]) : false;
|
||||
if (proto != null) {
|
||||
System.out.println("Using secure protocol: " + proto);
|
||||
POP3SClient pOP3SClient = new POP3SClient(proto, implicit);
|
||||
} else {
|
||||
pop3 = new POP3Client();
|
||||
}
|
||||
if (arg0.length == 2) {
|
||||
port = Integer.parseInt(arg0[1]);
|
||||
} else {
|
||||
port = pop3.getDefaultPort();
|
||||
}
|
||||
System.out.println("Connecting to server " + server + " on " + port);
|
||||
pop3.setDefaultTimeout(60000);
|
||||
pop3.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
try {
|
||||
pop3.connect(server);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not connect to server.");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!pop3.login(username, password)) {
|
||||
System.err.println("Could not login to server. Check password.");
|
||||
pop3.disconnect();
|
||||
return;
|
||||
}
|
||||
POP3MessageInfo status = pop3.status();
|
||||
if (status == null) {
|
||||
System.err.println("Could not retrieve status.");
|
||||
pop3.logout();
|
||||
pop3.disconnect();
|
||||
return;
|
||||
}
|
||||
System.out.println("Status: " + status);
|
||||
POP3MessageInfo[] messages = pop3.listMessages();
|
||||
if (messages == null) {
|
||||
System.err.println("Could not retrieve message list.");
|
||||
pop3.logout();
|
||||
pop3.disconnect();
|
||||
return;
|
||||
}
|
||||
if (messages.length == 0) {
|
||||
System.out.println("No messages");
|
||||
pop3.logout();
|
||||
pop3.disconnect();
|
||||
return;
|
||||
}
|
||||
System.out.println("Message count: " + messages.length);
|
||||
for (POP3MessageInfo msginfo : messages) {
|
||||
BufferedReader reader = (BufferedReader)pop3.retrieveMessageTop(msginfo.number, 0);
|
||||
if (reader == null) {
|
||||
System.err.println("Could not retrieve message header.");
|
||||
pop3.logout();
|
||||
pop3.disconnect();
|
||||
return;
|
||||
}
|
||||
printMessageInfo(reader, msginfo.number);
|
||||
}
|
||||
pop3.logout();
|
||||
pop3.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\POP3Mail.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,92 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.io.Util;
|
||||
import org.apache.commons.net.smtp.SMTPClient;
|
||||
import org.apache.commons.net.smtp.SMTPReply;
|
||||
import org.apache.commons.net.smtp.SimpleSMTPHeader;
|
||||
|
||||
public final class SMTPMail {
|
||||
public static void main(String[] args) {
|
||||
List<String> ccList = new ArrayList<String>();
|
||||
FileReader fileReader = null;
|
||||
if (args.length < 1) {
|
||||
System.err.println("Usage: mail smtpserver");
|
||||
System.exit(1);
|
||||
}
|
||||
String server = args[0];
|
||||
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {
|
||||
System.out.print("From: ");
|
||||
System.out.flush();
|
||||
String sender = stdin.readLine();
|
||||
System.out.print("To: ");
|
||||
System.out.flush();
|
||||
String recipient = stdin.readLine();
|
||||
System.out.print("Subject: ");
|
||||
System.out.flush();
|
||||
String subject = stdin.readLine();
|
||||
SimpleSMTPHeader header = new SimpleSMTPHeader(sender, recipient, subject);
|
||||
while (true) {
|
||||
System.out.print("CC <enter one address per line, hit enter to end>: ");
|
||||
System.out.flush();
|
||||
String cc = stdin.readLine();
|
||||
if (cc == null || cc.length() == 0)
|
||||
break;
|
||||
header.addCC(cc.trim());
|
||||
ccList.add(cc.trim());
|
||||
}
|
||||
System.out.print("Filename: ");
|
||||
System.out.flush();
|
||||
String filename = stdin.readLine();
|
||||
try {
|
||||
fileReader = new FileReader(filename);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("File not found. " + e.getMessage());
|
||||
}
|
||||
SMTPClient client = new SMTPClient();
|
||||
client.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
client.connect(server);
|
||||
if (!SMTPReply.isPositiveCompletion(client.getReplyCode())) {
|
||||
client.disconnect();
|
||||
System.err.println("SMTP server refused connection.");
|
||||
System.exit(1);
|
||||
}
|
||||
client.login();
|
||||
client.setSender(sender);
|
||||
client.addRecipient(recipient);
|
||||
for (String recpt : ccList)
|
||||
client.addRecipient(recpt);
|
||||
Writer writer = client.sendMessageData();
|
||||
if (writer != null) {
|
||||
writer.write(header.toString());
|
||||
Util.copyReader(fileReader, writer);
|
||||
writer.close();
|
||||
client.completePendingCommand();
|
||||
}
|
||||
if (fileReader != null)
|
||||
fileReader.close();
|
||||
client.logout();
|
||||
client.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\SMTPMail.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,35 @@
|
||||
package examples.mail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.Console;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Locale;
|
||||
|
||||
class Utils {
|
||||
static String getPassword(String username, String password) throws IOException {
|
||||
if ("-".equals(password)) {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||
password = in.readLine();
|
||||
} else if ("*".equals(password)) {
|
||||
Console con = System.console();
|
||||
if (con != null) {
|
||||
char[] pwd = con.readPassword("Password for " + username + ": ", new Object[0]);
|
||||
password = new String(pwd);
|
||||
} else {
|
||||
throw new IOException("Cannot access Console");
|
||||
}
|
||||
} else if (password.equals(password.toUpperCase(Locale.ROOT))) {
|
||||
String tmp = System.getenv(password);
|
||||
if (tmp != null)
|
||||
password = tmp;
|
||||
}
|
||||
return password;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\mail\Utils.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,66 @@
|
||||
package examples.nntp;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.SocketException;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.nntp.NNTPClient;
|
||||
import org.apache.commons.net.nntp.NewsgroupInfo;
|
||||
|
||||
public class ArticleReader {
|
||||
public static void main(String[] args) throws SocketException, IOException {
|
||||
BufferedReader brHdr, brBody;
|
||||
if (args.length != 2 && args.length != 3 && args.length != 5) {
|
||||
System.out.println("Usage: MessageThreading <hostname> <groupname> [<article specifier> [<user> <password>]]");
|
||||
return;
|
||||
}
|
||||
String hostname = args[0];
|
||||
String newsgroup = args[1];
|
||||
String articleSpec = (args.length >= 3) ? args[2] : null;
|
||||
NNTPClient client = new NNTPClient();
|
||||
client.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
client.connect(hostname);
|
||||
if (args.length == 5) {
|
||||
String user = args[3];
|
||||
String password = args[4];
|
||||
if (!client.authenticate(user, password)) {
|
||||
System.out.println("Authentication failed for user " + user + "!");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
NewsgroupInfo group = new NewsgroupInfo();
|
||||
client.selectNewsgroup(newsgroup, group);
|
||||
if (articleSpec != null) {
|
||||
brHdr = (BufferedReader)client.retrieveArticleHeader(articleSpec);
|
||||
} else {
|
||||
long articleNum = group.getLastArticleLong();
|
||||
brHdr = client.retrieveArticleHeader(articleNum);
|
||||
}
|
||||
if (brHdr != null) {
|
||||
String line;
|
||||
while ((line = brHdr.readLine()) != null)
|
||||
System.out.println(line);
|
||||
brHdr.close();
|
||||
}
|
||||
if (articleSpec != null) {
|
||||
brBody = (BufferedReader)client.retrieveArticleBody(articleSpec);
|
||||
} else {
|
||||
long articleNum = group.getLastArticleLong();
|
||||
brBody = client.retrieveArticleBody(articleNum);
|
||||
}
|
||||
if (brBody != null) {
|
||||
String line;
|
||||
while ((line = brBody.readLine()) != null)
|
||||
System.out.println(line);
|
||||
brBody.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\nntp\ArticleReader.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,65 @@
|
||||
package examples.nntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.nntp.Article;
|
||||
import org.apache.commons.net.nntp.NNTPClient;
|
||||
import org.apache.commons.net.nntp.NewsgroupInfo;
|
||||
|
||||
public class ExtendedNNTPOps {
|
||||
NNTPClient client;
|
||||
|
||||
public ExtendedNNTPOps() {
|
||||
this.client = new NNTPClient();
|
||||
this.client.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
}
|
||||
|
||||
private void demo(String host, String user, String password) {
|
||||
try {
|
||||
this.client.connect(host);
|
||||
if (user != null && password != null) {
|
||||
boolean success = this.client.authenticate(user, password);
|
||||
if (success) {
|
||||
System.out.println("Authentication succeeded");
|
||||
} else {
|
||||
System.out.println("Authentication failed, error =" + this.client.getReplyString());
|
||||
}
|
||||
}
|
||||
NewsgroupInfo testGroup = new NewsgroupInfo();
|
||||
this.client.selectNewsgroup("alt.test", testGroup);
|
||||
long lowArticleNumber = testGroup.getFirstArticleLong();
|
||||
long highArticleNumber = lowArticleNumber + 100L;
|
||||
Iterable<Article> articles = this.client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
|
||||
for (Article article : articles) {
|
||||
if (article.isDummy()) {
|
||||
System.out.println("Could not parse: " + article.getSubject());
|
||||
continue;
|
||||
}
|
||||
System.out.println(article.getSubject());
|
||||
}
|
||||
NewsgroupInfo[] fanGroups = this.client.listNewsgroups("alt.fan.*");
|
||||
for (NewsgroupInfo fanGroup : fanGroups)
|
||||
System.out.println(fanGroup.getNewsgroup());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int argc = args.length;
|
||||
if (argc < 1) {
|
||||
System.err.println("usage: ExtendedNNTPOps nntpserver [username password]");
|
||||
System.exit(1);
|
||||
}
|
||||
ExtendedNNTPOps ops = new ExtendedNNTPOps();
|
||||
ops.demo(args[0], (argc >= 3) ? args[1] : null, (argc >= 3) ? args[2] : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\nntp\ExtendedNNTPOps.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,52 @@
|
||||
package examples.nntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.net.nntp.NNTPClient;
|
||||
import org.apache.commons.net.nntp.NewsgroupInfo;
|
||||
|
||||
public final class ListNewsgroups {
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.err.println("Usage: newsgroups newsserver [pattern]");
|
||||
return;
|
||||
}
|
||||
NNTPClient client = new NNTPClient();
|
||||
String pattern = (args.length >= 2) ? args[1] : "";
|
||||
try {
|
||||
client.connect(args[0]);
|
||||
int j = 0;
|
||||
try {
|
||||
for (String s : client.iterateNewsgroupListing(pattern)) {
|
||||
j++;
|
||||
System.out.println(s);
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
System.out.println(j);
|
||||
j = 0;
|
||||
for (NewsgroupInfo n : client.iterateNewsgroups(pattern)) {
|
||||
j++;
|
||||
System.out.println(n.getNewsgroup());
|
||||
}
|
||||
System.out.println(j);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (client.isConnected())
|
||||
client.disconnect();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error disconnecting from server.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\nntp\ListNewsgroups.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,57 @@
|
||||
package examples.nntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.SocketException;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.nntp.Article;
|
||||
import org.apache.commons.net.nntp.NNTPClient;
|
||||
import org.apache.commons.net.nntp.NewsgroupInfo;
|
||||
import org.apache.commons.net.nntp.Threader;
|
||||
|
||||
public class MessageThreading {
|
||||
public static void main(String[] args) throws SocketException, IOException {
|
||||
if (args.length != 2 && args.length != 4) {
|
||||
System.out.println("Usage: MessageThreading <hostname> <groupname> [<user> <password>]");
|
||||
return;
|
||||
}
|
||||
String hostname = args[0];
|
||||
String newsgroup = args[1];
|
||||
NNTPClient client = new NNTPClient();
|
||||
client.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
client.connect(hostname);
|
||||
if (args.length == 4) {
|
||||
String user = args[2];
|
||||
String password = args[3];
|
||||
if (!client.authenticate(user, password)) {
|
||||
System.out.println("Authentication failed for user " + user + "!");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
String[] fmt = client.listOverviewFmt();
|
||||
if (fmt != null) {
|
||||
System.out.println("LIST OVERVIEW.FMT:");
|
||||
for (String s : fmt)
|
||||
System.out.println(s);
|
||||
} else {
|
||||
System.out.println("Failed to get OVERVIEW.FMT");
|
||||
}
|
||||
NewsgroupInfo group = new NewsgroupInfo();
|
||||
client.selectNewsgroup(newsgroup, group);
|
||||
long lowArticleNumber = group.getFirstArticleLong();
|
||||
long highArticleNumber = lowArticleNumber + 5000L;
|
||||
System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
|
||||
Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
|
||||
System.out.println("Building message thread tree...");
|
||||
Threader threader = new Threader();
|
||||
Article root = (Article)threader.thread(articles);
|
||||
Article.printThread(root, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\nntp\MessageThreading.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,23 @@
|
||||
package examples.nntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.net.nntp.Article;
|
||||
import org.apache.commons.net.nntp.NNTPClient;
|
||||
|
||||
public class NNTPUtils {
|
||||
public static List<Article> getArticleInfo(NNTPClient client, long lowArticleNumber, long highArticleNumber) throws IOException {
|
||||
List<Article> articles = new ArrayList<Article>();
|
||||
Iterable<Article> arts = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
|
||||
for (Article article : arts)
|
||||
articles.add(article);
|
||||
return articles;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\nntp\NNTPUtils.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,101 @@
|
||||
package examples.nntp;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import org.apache.commons.net.PrintCommandListener;
|
||||
import org.apache.commons.net.ProtocolCommandListener;
|
||||
import org.apache.commons.net.io.Util;
|
||||
import org.apache.commons.net.nntp.NNTPClient;
|
||||
import org.apache.commons.net.nntp.NNTPReply;
|
||||
import org.apache.commons.net.nntp.SimpleNNTPHeader;
|
||||
|
||||
public final class PostMessage {
|
||||
public static void main(String[] args) {
|
||||
FileReader fileReader = null;
|
||||
if (args.length < 1) {
|
||||
System.err.println("Usage: post newsserver");
|
||||
System.exit(1);
|
||||
}
|
||||
String server = args[0];
|
||||
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {
|
||||
System.out.print("From: ");
|
||||
System.out.flush();
|
||||
String from = stdin.readLine();
|
||||
System.out.print("Subject: ");
|
||||
System.out.flush();
|
||||
String subject = stdin.readLine();
|
||||
SimpleNNTPHeader header = new SimpleNNTPHeader(from, subject);
|
||||
System.out.print("Newsgroup: ");
|
||||
System.out.flush();
|
||||
String newsgroup = stdin.readLine();
|
||||
header.addNewsgroup(newsgroup);
|
||||
while (true) {
|
||||
System.out.print("Additional Newsgroup <Hit enter to end>: ");
|
||||
System.out.flush();
|
||||
newsgroup = stdin.readLine();
|
||||
if (newsgroup == null)
|
||||
break;
|
||||
newsgroup = newsgroup.trim();
|
||||
if (newsgroup.length() == 0)
|
||||
break;
|
||||
header.addNewsgroup(newsgroup);
|
||||
}
|
||||
System.out.print("Organization: ");
|
||||
System.out.flush();
|
||||
String organization = stdin.readLine();
|
||||
System.out.print("References: ");
|
||||
System.out.flush();
|
||||
String references = stdin.readLine();
|
||||
if (organization != null && organization.length() > 0)
|
||||
header.addHeaderField("Organization", organization);
|
||||
if (references != null && references.length() > 0)
|
||||
header.addHeaderField("References", references);
|
||||
header.addHeaderField("X-Newsreader", "NetComponents");
|
||||
System.out.print("Filename: ");
|
||||
System.out.flush();
|
||||
String filename = stdin.readLine();
|
||||
try {
|
||||
fileReader = new FileReader(filename);
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("File not found. " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
NNTPClient client = new NNTPClient();
|
||||
client.addProtocolCommandListener((ProtocolCommandListener)new PrintCommandListener(new PrintWriter(System.out), true));
|
||||
client.connect(server);
|
||||
if (!NNTPReply.isPositiveCompletion(client.getReplyCode())) {
|
||||
client.disconnect();
|
||||
System.err.println("NNTP server refused connection.");
|
||||
System.exit(1);
|
||||
}
|
||||
if (client.isAllowedToPost()) {
|
||||
Writer writer = client.postArticle();
|
||||
if (writer != null) {
|
||||
writer.write(header.toString());
|
||||
Util.copyReader(fileReader, writer);
|
||||
writer.close();
|
||||
client.completePendingCommand();
|
||||
}
|
||||
}
|
||||
if (fileReader != null)
|
||||
fileReader.close();
|
||||
client.logout();
|
||||
client.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\nntp\PostMessage.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,110 @@
|
||||
package examples.ntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import org.apache.commons.net.ntp.NTPUDPClient;
|
||||
import org.apache.commons.net.ntp.NtpUtils;
|
||||
import org.apache.commons.net.ntp.NtpV3Packet;
|
||||
import org.apache.commons.net.ntp.TimeInfo;
|
||||
import org.apache.commons.net.ntp.TimeStamp;
|
||||
|
||||
public final class NTPClient {
|
||||
private static final NumberFormat numberFormat = new DecimalFormat("0.00");
|
||||
|
||||
public static void processResponse(TimeInfo info) {
|
||||
String refType;
|
||||
NtpV3Packet message = info.getMessage();
|
||||
int stratum = message.getStratum();
|
||||
if (stratum <= 0) {
|
||||
refType = "(Unspecified or Unavailable)";
|
||||
} else if (stratum == 1) {
|
||||
refType = "(Primary Reference; e.g., GPS)";
|
||||
} else {
|
||||
refType = "(Secondary Reference; e.g. via NTP or SNTP)";
|
||||
}
|
||||
System.out.println(" Stratum: " + stratum + " " + refType);
|
||||
int version = message.getVersion();
|
||||
int li = message.getLeapIndicator();
|
||||
System.out.println(" leap=" + li + ", version=" + version + ", precision=" + message.getPrecision());
|
||||
System.out.println(" mode: " + message.getModeName() + " (" + message.getMode() + ")");
|
||||
int poll = message.getPoll();
|
||||
System.out.println(" poll: " + ((poll <= 0) ? 1 : (int)Math.pow(2.0D, poll)) + " seconds" + " (2 ** " + poll + ")");
|
||||
double disp = message.getRootDispersionInMillisDouble();
|
||||
System.out.println(" rootdelay=" + numberFormat.format(message.getRootDelayInMillisDouble()) + ", rootdispersion(ms): " + numberFormat.format(disp));
|
||||
int refId = message.getReferenceId();
|
||||
String refAddr = NtpUtils.getHostAddress(refId);
|
||||
String refName = null;
|
||||
if (refId != 0)
|
||||
if (refAddr.equals("127.127.1.0")) {
|
||||
refName = "LOCAL";
|
||||
} else if (stratum >= 2) {
|
||||
if (!refAddr.startsWith("127.127"))
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByName(refAddr);
|
||||
String name = addr.getHostName();
|
||||
if (name != null && !name.equals(refAddr))
|
||||
refName = name;
|
||||
} catch (UnknownHostException e) {
|
||||
refName = NtpUtils.getReferenceClock(message);
|
||||
}
|
||||
} else if (version >= 3 && (stratum == 0 || stratum == 1)) {
|
||||
refName = NtpUtils.getReferenceClock(message);
|
||||
}
|
||||
if (refName != null && refName.length() > 1)
|
||||
refAddr = refAddr + " (" + refName + ")";
|
||||
System.out.println(" Reference Identifier:\t" + refAddr);
|
||||
TimeStamp refNtpTime = message.getReferenceTimeStamp();
|
||||
System.out.println(" Reference Timestamp:\t" + refNtpTime + " " + refNtpTime.toDateString());
|
||||
TimeStamp origNtpTime = message.getOriginateTimeStamp();
|
||||
System.out.println(" Originate Timestamp:\t" + origNtpTime + " " + origNtpTime.toDateString());
|
||||
long destTime = info.getReturnTime();
|
||||
TimeStamp rcvNtpTime = message.getReceiveTimeStamp();
|
||||
System.out.println(" Receive Timestamp:\t" + rcvNtpTime + " " + rcvNtpTime.toDateString());
|
||||
TimeStamp xmitNtpTime = message.getTransmitTimeStamp();
|
||||
System.out.println(" Transmit Timestamp:\t" + xmitNtpTime + " " + xmitNtpTime.toDateString());
|
||||
TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime);
|
||||
System.out.println(" Destination Timestamp:\t" + destNtpTime + " " + destNtpTime.toDateString());
|
||||
info.computeDetails();
|
||||
Long offsetValue = info.getOffset();
|
||||
Long delayValue = info.getDelay();
|
||||
String delay = (delayValue == null) ? "N/A" : delayValue.toString();
|
||||
String offset = (offsetValue == null) ? "N/A" : offsetValue.toString();
|
||||
System.out.println(" Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
System.err.println("Usage: NTPClient <hostname-or-address-list>");
|
||||
System.exit(1);
|
||||
}
|
||||
NTPUDPClient client = new NTPUDPClient();
|
||||
client.setDefaultTimeout(10000);
|
||||
try {
|
||||
client.open();
|
||||
for (String arg : args) {
|
||||
System.out.println();
|
||||
try {
|
||||
InetAddress hostAddr = InetAddress.getByName(arg);
|
||||
System.out.println("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
|
||||
TimeInfo info = client.getTime(hostAddr);
|
||||
processResponse(info);
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\ntp\NTPClient.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,130 @@
|
||||
package examples.ntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import org.apache.commons.net.ntp.NtpUtils;
|
||||
import org.apache.commons.net.ntp.NtpV3Impl;
|
||||
import org.apache.commons.net.ntp.TimeStamp;
|
||||
|
||||
public class SimpleNTPServer implements Runnable {
|
||||
private int port;
|
||||
|
||||
private volatile boolean running;
|
||||
|
||||
private boolean started;
|
||||
|
||||
private DatagramSocket socket;
|
||||
|
||||
public SimpleNTPServer() {
|
||||
this(123);
|
||||
}
|
||||
|
||||
public SimpleNTPServer(int port) {
|
||||
if (port < 0)
|
||||
throw new IllegalArgumentException();
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return this.running;
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
public void connect() throws IOException {
|
||||
if (this.socket == null) {
|
||||
this.socket = new DatagramSocket(this.port);
|
||||
if (this.port == 0)
|
||||
this.port = this.socket.getLocalPort();
|
||||
System.out.println("Running NTP service on port " + this.port + "/UDP");
|
||||
}
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
if (this.socket == null)
|
||||
connect();
|
||||
if (!this.started) {
|
||||
this.started = true;
|
||||
(new Thread(this)).start();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
this.running = true;
|
||||
byte[] buffer = new byte[48];
|
||||
DatagramPacket request = new DatagramPacket(buffer, buffer.length);
|
||||
do {
|
||||
try {
|
||||
this.socket.receive(request);
|
||||
long rcvTime = System.currentTimeMillis();
|
||||
handlePacket(request, rcvTime);
|
||||
} catch (IOException e) {
|
||||
if (this.running)
|
||||
e.printStackTrace();
|
||||
}
|
||||
} while (this.running);
|
||||
}
|
||||
|
||||
protected void handlePacket(DatagramPacket request, long rcvTime) throws IOException {
|
||||
NtpV3Impl ntpV3Impl = new NtpV3Impl();
|
||||
ntpV3Impl.setDatagramPacket(request);
|
||||
System.out.printf("NTP packet from %s mode=%s%n", new Object[] { request.getAddress().getHostAddress(), NtpUtils.getModeName(ntpV3Impl.getMode()) });
|
||||
if (ntpV3Impl.getMode() == 3) {
|
||||
NtpV3Impl ntpV3Impl1 = new NtpV3Impl();
|
||||
ntpV3Impl1.setStratum(1);
|
||||
ntpV3Impl1.setMode(4);
|
||||
ntpV3Impl1.setVersion(3);
|
||||
ntpV3Impl1.setPrecision(-20);
|
||||
ntpV3Impl1.setPoll(0);
|
||||
ntpV3Impl1.setRootDelay(62);
|
||||
ntpV3Impl1.setRootDispersion(1081);
|
||||
ntpV3Impl1.setOriginateTimeStamp(ntpV3Impl.getTransmitTimeStamp());
|
||||
ntpV3Impl1.setReceiveTimeStamp(TimeStamp.getNtpTime(rcvTime));
|
||||
ntpV3Impl1.setReferenceTime(ntpV3Impl1.getReceiveTimeStamp());
|
||||
ntpV3Impl1.setReferenceId(1279478784);
|
||||
ntpV3Impl1.setTransmitTime(TimeStamp.getNtpTime(System.currentTimeMillis()));
|
||||
DatagramPacket dp = ntpV3Impl1.getDatagramPacket();
|
||||
dp.setPort(request.getPort());
|
||||
dp.setAddress(request.getAddress());
|
||||
this.socket.send(dp);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.running = false;
|
||||
if (this.socket != null) {
|
||||
this.socket.close();
|
||||
this.socket = null;
|
||||
}
|
||||
this.started = false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int port = 123;
|
||||
if (args.length != 0)
|
||||
try {
|
||||
port = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException nfe) {
|
||||
nfe.printStackTrace();
|
||||
}
|
||||
SimpleNTPServer timeServer = new SimpleNTPServer(port);
|
||||
try {
|
||||
timeServer.start();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\ntp\SimpleNTPServer.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,54 @@
|
||||
package examples.ntp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import org.apache.commons.net.time.TimeTCPClient;
|
||||
import org.apache.commons.net.time.TimeUDPClient;
|
||||
|
||||
public final class TimeClient {
|
||||
public static final void timeTCP(String host) throws IOException {
|
||||
TimeTCPClient client = new TimeTCPClient();
|
||||
try {
|
||||
client.setDefaultTimeout(60000);
|
||||
client.connect(host);
|
||||
System.out.println(client.getDate());
|
||||
} finally {
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public static final void timeUDP(String host) throws IOException {
|
||||
TimeUDPClient client = new TimeUDPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.open();
|
||||
System.out.println(client.getDate(InetAddress.getByName(host)));
|
||||
client.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
timeTCP(args[0]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (args.length == 2 && args[0].equals("-udp")) {
|
||||
try {
|
||||
timeUDP(args[1]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Usage: TimeClient [-udp] <hostname>");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\ntp\TimeClient.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,208 @@
|
||||
package examples.telnet;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.StringTokenizer;
|
||||
import org.apache.commons.net.telnet.EchoOptionHandler;
|
||||
import org.apache.commons.net.telnet.InvalidTelnetOptionException;
|
||||
import org.apache.commons.net.telnet.SimpleOptionHandler;
|
||||
import org.apache.commons.net.telnet.SuppressGAOptionHandler;
|
||||
import org.apache.commons.net.telnet.TelnetClient;
|
||||
import org.apache.commons.net.telnet.TelnetNotificationHandler;
|
||||
import org.apache.commons.net.telnet.TelnetOptionHandler;
|
||||
import org.apache.commons.net.telnet.TerminalTypeOptionHandler;
|
||||
|
||||
public class TelnetClientExample implements Runnable, TelnetNotificationHandler {
|
||||
static TelnetClient tc = null;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int remoteport;
|
||||
FileOutputStream fout = null;
|
||||
if (args.length < 1) {
|
||||
System.err.println("Usage: TelnetClientExample <remote-ip> [<remote-port>]");
|
||||
System.exit(1);
|
||||
}
|
||||
String remoteip = args[0];
|
||||
if (args.length > 1) {
|
||||
remoteport = (new Integer(args[1])).intValue();
|
||||
} else {
|
||||
remoteport = 23;
|
||||
}
|
||||
try {
|
||||
fout = new FileOutputStream("spy.log", true);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception while opening the spy file: " + e.getMessage());
|
||||
}
|
||||
tc = new TelnetClient();
|
||||
TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
|
||||
EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
|
||||
SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);
|
||||
try {
|
||||
tc.addOptionHandler((TelnetOptionHandler)ttopt);
|
||||
tc.addOptionHandler((TelnetOptionHandler)echoopt);
|
||||
tc.addOptionHandler((TelnetOptionHandler)gaopt);
|
||||
} catch (InvalidTelnetOptionException e) {
|
||||
System.err.println("Error registering option handlers: " + e.getMessage());
|
||||
}
|
||||
while (true) {
|
||||
boolean end_loop = false;
|
||||
try {
|
||||
tc.connect(remoteip, remoteport);
|
||||
Thread reader = new Thread(new TelnetClientExample());
|
||||
tc.registerNotifHandler(new TelnetClientExample());
|
||||
System.out.println("TelnetClientExample");
|
||||
System.out.println("Type AYT to send an AYT telnet command");
|
||||
System.out.println("Type OPT to print a report of status of options (0-24)");
|
||||
System.out.println("Type REGISTER to register a new SimpleOptionHandler");
|
||||
System.out.println("Type UNREGISTER to unregister an OptionHandler");
|
||||
System.out.println("Type SPY to register the spy (connect to port 3333 to spy)");
|
||||
System.out.println("Type UNSPY to stop spying the connection");
|
||||
System.out.println("Type ^[A-Z] to send the control character; use ^^ to send ^");
|
||||
reader.start();
|
||||
OutputStream outstr = tc.getOutputStream();
|
||||
byte[] buff = new byte[1024];
|
||||
int ret_read = 0;
|
||||
do {
|
||||
try {
|
||||
ret_read = System.in.read(buff);
|
||||
if (ret_read > 0) {
|
||||
String line = new String(buff, 0, ret_read);
|
||||
if (line.startsWith("AYT")) {
|
||||
try {
|
||||
System.out.println("Sending AYT");
|
||||
System.out.println("AYT response:" + tc.sendAYT(5000L));
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception waiting AYT response: " + e.getMessage());
|
||||
}
|
||||
} else if (line.startsWith("OPT")) {
|
||||
System.out.println("Status of options:");
|
||||
for (int ii = 0; ii < 25; ii++)
|
||||
System.out.println("Local Option " + ii + ":" + tc.getLocalOptionState(ii) + " Remote Option " + ii + ":" + tc.getRemoteOptionState(ii));
|
||||
} else if (line.startsWith("REGISTER")) {
|
||||
StringTokenizer st = new StringTokenizer(new String(buff));
|
||||
try {
|
||||
st.nextToken();
|
||||
int opcode = Integer.parseInt(st.nextToken());
|
||||
boolean initlocal = Boolean.parseBoolean(st.nextToken());
|
||||
boolean initremote = Boolean.parseBoolean(st.nextToken());
|
||||
boolean acceptlocal = Boolean.parseBoolean(st.nextToken());
|
||||
boolean acceptremote = Boolean.parseBoolean(st.nextToken());
|
||||
SimpleOptionHandler opthand = new SimpleOptionHandler(opcode, initlocal, initremote, acceptlocal, acceptremote);
|
||||
tc.addOptionHandler((TelnetOptionHandler)opthand);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof InvalidTelnetOptionException) {
|
||||
System.err.println("Error registering option: " + e.getMessage());
|
||||
} else {
|
||||
System.err.println("Invalid REGISTER command.");
|
||||
System.err.println("Use REGISTER optcode initlocal initremote acceptlocal acceptremote");
|
||||
System.err.println("(optcode is an integer.)");
|
||||
System.err.println("(initlocal, initremote, acceptlocal, acceptremote are boolean)");
|
||||
}
|
||||
}
|
||||
} else if (line.startsWith("UNREGISTER")) {
|
||||
StringTokenizer st = new StringTokenizer(new String(buff));
|
||||
try {
|
||||
st.nextToken();
|
||||
int opcode = (new Integer(st.nextToken())).intValue();
|
||||
tc.deleteOptionHandler(opcode);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof InvalidTelnetOptionException) {
|
||||
System.err.println("Error unregistering option: " + e.getMessage());
|
||||
} else {
|
||||
System.err.println("Invalid UNREGISTER command.");
|
||||
System.err.println("Use UNREGISTER optcode");
|
||||
System.err.println("(optcode is an integer)");
|
||||
}
|
||||
}
|
||||
} else if (line.startsWith("SPY")) {
|
||||
tc.registerSpyStream(fout);
|
||||
} else if (line.startsWith("UNSPY")) {
|
||||
tc.stopSpyStream();
|
||||
} else if (line.matches("^\\^[A-Z^]\\r?\\n?$")) {
|
||||
byte toSend = buff[1];
|
||||
if (toSend == 94) {
|
||||
outstr.write(toSend);
|
||||
} else {
|
||||
outstr.write(toSend - 65 + 1);
|
||||
}
|
||||
outstr.flush();
|
||||
} else {
|
||||
try {
|
||||
outstr.write(buff, 0, ret_read);
|
||||
outstr.flush();
|
||||
} catch (IOException e) {
|
||||
end_loop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception while reading keyboard:" + e.getMessage());
|
||||
end_loop = true;
|
||||
}
|
||||
} while (ret_read > 0 && !end_loop);
|
||||
try {
|
||||
tc.disconnect();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception while connecting:" + e.getMessage());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception while connecting:" + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void receivedNegotiation(int negotiation_code, int option_code) {
|
||||
String command = null;
|
||||
switch (negotiation_code) {
|
||||
case 1:
|
||||
command = "DO";
|
||||
break;
|
||||
case 2:
|
||||
command = "DONT";
|
||||
break;
|
||||
case 3:
|
||||
command = "WILL";
|
||||
break;
|
||||
case 4:
|
||||
command = "WONT";
|
||||
break;
|
||||
case 5:
|
||||
command = "COMMAND";
|
||||
break;
|
||||
default:
|
||||
command = Integer.toString(negotiation_code);
|
||||
break;
|
||||
}
|
||||
System.out.println("Received " + command + " for option code " + option_code);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
InputStream instr = tc.getInputStream();
|
||||
try {
|
||||
byte[] buff = new byte[1024];
|
||||
int ret_read = 0;
|
||||
do {
|
||||
ret_read = instr.read(buff);
|
||||
if (ret_read <= 0)
|
||||
continue;
|
||||
System.out.print(new String(buff, 0, ret_read));
|
||||
} while (ret_read >= 0);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception while reading socket:" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
tc.disconnect();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Exception while closing telnet:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\telnet\TelnetClientExample.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,31 @@
|
||||
package examples.telnet;
|
||||
|
||||
import examples.util.IOUtil;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.net.telnet.TelnetClient;
|
||||
|
||||
public final class WeatherTelnet {
|
||||
public static final void main(String[] args) {
|
||||
TelnetClient telnet = new TelnetClient();
|
||||
try {
|
||||
telnet.connect("rainmaker.wunderground.com", 3000);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
IOUtil.readWrite(telnet.getInputStream(), telnet.getOutputStream(), System.in, System.out);
|
||||
try {
|
||||
telnet.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\examples\telnet\WeatherTelnet.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,78 @@
|
||||
package examples.unix;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import org.apache.commons.net.chargen.CharGenTCPClient;
|
||||
import org.apache.commons.net.chargen.CharGenUDPClient;
|
||||
|
||||
public final class chargen {
|
||||
public static final void chargenTCP(String host) throws IOException {
|
||||
int lines = 100;
|
||||
CharGenTCPClient client = new CharGenTCPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.connect(host);
|
||||
BufferedReader chargenInput = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
||||
while (lines-- > 0) {
|
||||
String line;
|
||||
if ((line = chargenInput.readLine()) == null)
|
||||
break;
|
||||
System.out.println(line);
|
||||
}
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
public static final void chargenUDP(String host) throws IOException {
|
||||
int packets = 50;
|
||||
InetAddress address = InetAddress.getByName(host);
|
||||
CharGenUDPClient client = new CharGenUDPClient();
|
||||
client.open();
|
||||
client.setSoTimeout(5000);
|
||||
while (packets-- > 0) {
|
||||
byte[] data;
|
||||
client.send(address);
|
||||
try {
|
||||
data = client.receive();
|
||||
} catch (SocketException e) {
|
||||
System.err.println("SocketException: Timed out and dropped packet");
|
||||
continue;
|
||||
} catch (InterruptedIOException e) {
|
||||
System.err.println("InterruptedIOException: Timed out and dropped packet");
|
||||
continue;
|
||||
}
|
||||
System.out.write(data);
|
||||
System.out.flush();
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
chargenTCP(args[0]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (args.length == 2 && args[0].equals("-udp")) {
|
||||
try {
|
||||
chargenUDP(args[1]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Usage: chargen [-udp] <hostname>");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\chargen.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,51 @@
|
||||
package examples.unix;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import org.apache.commons.net.daytime.DaytimeTCPClient;
|
||||
import org.apache.commons.net.daytime.DaytimeUDPClient;
|
||||
|
||||
public final class daytime {
|
||||
public static final void daytimeTCP(String host) throws IOException {
|
||||
DaytimeTCPClient client = new DaytimeTCPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.connect(host);
|
||||
System.out.println(client.getTime().trim());
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
public static final void daytimeUDP(String host) throws IOException {
|
||||
DaytimeUDPClient client = new DaytimeUDPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.open();
|
||||
System.out.println(client.getTime(InetAddress.getByName(host)).trim());
|
||||
client.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
daytimeTCP(args[0]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (args.length == 2 && args[0].equals("-udp")) {
|
||||
try {
|
||||
daytimeUDP(args[1]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Usage: daytime [-udp] <hostname>");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\daytime.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,88 @@
|
||||
package examples.unix;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import org.apache.commons.net.echo.EchoTCPClient;
|
||||
import org.apache.commons.net.echo.EchoUDPClient;
|
||||
|
||||
public final class echo {
|
||||
public static final void echoTCP(String host) throws IOException {
|
||||
EchoTCPClient client = new EchoTCPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.connect(host);
|
||||
System.out.println("Connected to " + host + ".");
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
||||
PrintWriter echoOutput = new PrintWriter(new OutputStreamWriter(client.getOutputStream()), true);
|
||||
BufferedReader echoInput = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
||||
String line;
|
||||
while ((line = input.readLine()) != null) {
|
||||
echoOutput.println(line);
|
||||
System.out.println(echoInput.readLine());
|
||||
}
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
public static final void echoUDP(String host) throws IOException {
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
||||
InetAddress address = InetAddress.getByName(host);
|
||||
EchoUDPClient client = new EchoUDPClient();
|
||||
client.open();
|
||||
client.setSoTimeout(5000);
|
||||
System.out.println("Ready to echo to " + host + ".");
|
||||
String line;
|
||||
while ((line = input.readLine()) != null) {
|
||||
byte[] data = line.getBytes();
|
||||
client.send(data, address);
|
||||
int count = 0;
|
||||
do {
|
||||
int length;
|
||||
try {
|
||||
length = client.receive(data);
|
||||
} catch (SocketException e) {
|
||||
System.err.println("SocketException: Timed out and dropped packet");
|
||||
break;
|
||||
} catch (InterruptedIOException e) {
|
||||
System.err.println("InterruptedIOException: Timed out and dropped packet");
|
||||
break;
|
||||
}
|
||||
System.out.print(new String(data, 0, length));
|
||||
count += length;
|
||||
} while (count < data.length);
|
||||
System.out.println();
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
echoTCP(args[0]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (args.length == 2 && args[0].equals("-udp")) {
|
||||
try {
|
||||
echoUDP(args[1]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Usage: echo [-udp] <hostname>");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\echo.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,82 @@
|
||||
package examples.unix;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import org.apache.commons.net.finger.FingerClient;
|
||||
|
||||
public final class finger {
|
||||
public static void main(String[] args) {
|
||||
boolean longOutput = false;
|
||||
int arg = 0;
|
||||
InetAddress address = null;
|
||||
while (arg < args.length && args[arg].startsWith("-")) {
|
||||
if (args[arg].equals("-l")) {
|
||||
longOutput = true;
|
||||
} else {
|
||||
System.err.println("usage: finger [-l] [[[handle][@<server>]] ...]");
|
||||
System.exit(1);
|
||||
}
|
||||
arg++;
|
||||
}
|
||||
FingerClient fingerClient = new FingerClient();
|
||||
fingerClient.setDefaultTimeout(60000);
|
||||
if (arg >= args.length) {
|
||||
try {
|
||||
address = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Error unknown host: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
fingerClient.connect(address);
|
||||
System.out.print(fingerClient.query(longOutput));
|
||||
fingerClient.disconnect();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error I/O exception: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
while (arg < args.length) {
|
||||
String handle;
|
||||
int index = args[arg].lastIndexOf("@");
|
||||
if (index == -1) {
|
||||
handle = args[arg];
|
||||
try {
|
||||
address = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Error unknown host: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
handle = args[arg].substring(0, index);
|
||||
String host = args[arg].substring(index + 1);
|
||||
try {
|
||||
address = InetAddress.getByName(host);
|
||||
System.out.println("[" + address.getHostName() + "]");
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Error unknown host: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
try {
|
||||
fingerClient.connect(address);
|
||||
System.out.print(fingerClient.query(longOutput, handle));
|
||||
fingerClient.disconnect();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error I/O exception: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
arg++;
|
||||
if (arg != args.length)
|
||||
System.out.print("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\finger.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,48 @@
|
||||
package examples.unix;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import org.apache.commons.net.whois.WhoisClient;
|
||||
|
||||
public final class fwhois {
|
||||
public static void main(String[] args) {
|
||||
String handle, host;
|
||||
InetAddress address = null;
|
||||
if (args.length != 1) {
|
||||
System.err.println("usage: fwhois handle[@<server>]");
|
||||
System.exit(1);
|
||||
}
|
||||
int index = args[0].lastIndexOf("@");
|
||||
WhoisClient whois = new WhoisClient();
|
||||
whois.setDefaultTimeout(60000);
|
||||
if (index == -1) {
|
||||
handle = args[0];
|
||||
host = "whois.internic.net";
|
||||
} else {
|
||||
handle = args[0].substring(0, index);
|
||||
host = args[0].substring(index + 1);
|
||||
}
|
||||
try {
|
||||
address = InetAddress.getByName(host);
|
||||
System.out.println("[" + address.getHostName() + "]");
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Error unknown host: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
whois.connect(address);
|
||||
System.out.print(whois.query(handle));
|
||||
whois.disconnect();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error I/O exception: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\fwhois.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,51 @@
|
||||
package examples.unix;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import org.apache.commons.net.time.TimeTCPClient;
|
||||
import org.apache.commons.net.time.TimeUDPClient;
|
||||
|
||||
public final class rdate {
|
||||
public static final void timeTCP(String host) throws IOException {
|
||||
TimeTCPClient client = new TimeTCPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.connect(host);
|
||||
System.out.println(client.getDate().toString());
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
public static final void timeUDP(String host) throws IOException {
|
||||
TimeUDPClient client = new TimeUDPClient();
|
||||
client.setDefaultTimeout(60000);
|
||||
client.open();
|
||||
System.out.println(client.getDate(InetAddress.getByName(host)).toString());
|
||||
client.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
timeTCP(args[0]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (args.length == 2 && args[0].equals("-udp")) {
|
||||
try {
|
||||
timeUDP(args[1]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Usage: rdate [-udp] <hostname>");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\rdate.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,51 @@
|
||||
package examples.unix;
|
||||
|
||||
import examples.util.IOUtil;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.net.bsd.RExecClient;
|
||||
|
||||
public final class rexec {
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 4) {
|
||||
System.err.println("Usage: rexec <hostname> <username> <password> <command>");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
RExecClient client = new RExecClient();
|
||||
String server = args[0];
|
||||
String username = args[1];
|
||||
String password = args[2];
|
||||
String command = args[3];
|
||||
try {
|
||||
client.connect(server);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not connect to server.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
client.rexec(username, password, command);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (IOException f) {}
|
||||
e.printStackTrace();
|
||||
System.err.println("Could not execute command.");
|
||||
System.exit(1);
|
||||
}
|
||||
IOUtil.readWrite(client.getInputStream(), client.getOutputStream(), System.in, System.out);
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\rexec.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,51 @@
|
||||
package examples.unix;
|
||||
|
||||
import examples.util.IOUtil;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.net.bsd.RLoginClient;
|
||||
|
||||
public final class rlogin {
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 4) {
|
||||
System.err.println("Usage: rlogin <hostname> <localuser> <remoteuser> <terminal>");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
RLoginClient client = new RLoginClient();
|
||||
String server = args[0];
|
||||
String localuser = args[1];
|
||||
String remoteuser = args[2];
|
||||
String terminal = args[3];
|
||||
try {
|
||||
client.connect(server);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not connect to server.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
client.rlogin(localuser, remoteuser, terminal);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (IOException f) {}
|
||||
e.printStackTrace();
|
||||
System.err.println("rlogin authentication failed.");
|
||||
System.exit(1);
|
||||
}
|
||||
IOUtil.readWrite(client.getInputStream(), client.getOutputStream(), System.in, System.out);
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\rlogin.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,51 @@
|
||||
package examples.unix;
|
||||
|
||||
import examples.util.IOUtil;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.net.bsd.RCommandClient;
|
||||
|
||||
public final class rshell {
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 4) {
|
||||
System.err.println("Usage: rshell <hostname> <localuser> <remoteuser> <command>");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
RCommandClient client = new RCommandClient();
|
||||
String server = args[0];
|
||||
String localuser = args[1];
|
||||
String remoteuser = args[2];
|
||||
String command = args[3];
|
||||
try {
|
||||
client.connect(server);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not connect to server.");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
client.rcommand(localuser, remoteuser, command);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (IOException f) {}
|
||||
e.printStackTrace();
|
||||
System.err.println("Could not execute command.");
|
||||
System.exit(1);
|
||||
}
|
||||
IOUtil.readWrite(client.getInputStream(), client.getOutputStream(), System.in, System.out);
|
||||
try {
|
||||
client.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\unix\rshell.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
@ -0,0 +1,46 @@
|
||||
package examples.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import org.apache.commons.net.io.Util;
|
||||
|
||||
public final class IOUtil {
|
||||
public static final void readWrite(final InputStream remoteInput, final OutputStream remoteOutput, final InputStream localInput, final OutputStream localOutput) {
|
||||
Thread reader = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
int ch;
|
||||
while (!interrupted() && (ch = localInput.read()) != -1) {
|
||||
remoteOutput.write(ch);
|
||||
remoteOutput.flush();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
};
|
||||
Thread writer = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
Util.copyStream(remoteInput, localOutput);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
writer.setPriority(Thread.currentThread().getPriority() + 1);
|
||||
writer.start();
|
||||
reader.setDaemon(true);
|
||||
reader.start();
|
||||
try {
|
||||
writer.join();
|
||||
reader.interrupt();
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Location: C:\Users\sddd1\Desktop\anpr_img_send.jar!\example\\util\IOUtil.class
|
||||
* Java compiler version: 6 (50.0)
|
||||
* JD-Core Version: 1.1.3
|
||||
*/
|
||||
Loading…
Reference in New Issue