package batchic;import java.io.PrintWriter;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.io.File;public class bicMain {
private static String strRootFilePate = "";
public static void main(String[] args) {
strRootFilePate = bicUtil.GetRootPath();
System.out.println("********************************************************");
System.out.println("BATCH MAIL SENDER (C) 2003-8 1.0.1 YangGuoqing");
System.out.println("");
System.out.println("MODIFY HISTORY");
System.out.println("1.0--1.0.1 : ADD AUTO-DETECT APPLICATION ROOT PATH");
System.out.println(" : CHANGE MAIL TYPE TO 0,1,3,9 FOR SENDING ");
System.out.println(" DIFFERENT SUBJECT MAIL");
System.out.println("********************************************************");
System.out.println("");
char chrMailType = 0;
while(true){
if(chrMailType != 10 && chrMailType != 13){
System.out.println("PLEASE SELECT \"0\" , \"1\" , \"3\" or \"9\" FROM YOUR KEYBOARD");
System.out.println(" 0: MAIL DATE IS [TODAY]");
System.out.println(" 1: MAIL DATE IS [YESTODAY]");
System.out.println(" 3: MAIL DATE IS [LAST WEEKEND]");
System.out.println(" 9: QUIT");
System.out.print("CHOOSE TYPE:");
}
try {
chrMailType = (char)System.in.read();
}
catch (Exception ex) {
System.out.println("[Error:]Can't read from keyboard input.");
ex.printStackTrace();
}
if(chrMailType !='0' && chrMailType !='1' && chrMailType !='3' && chrMailType !='9'){
if(chrMailType != 10 && chrMailType != 13){
System.out.print("KEYBOARD INPUT ERROR["+ chrMailType +"],");
}
}else if(chrMailType == '9'){
System.exit(0);
}else{
break;
}
}
System.out.print("SET MAIL CONFIG");
String strFilePate = strRootFilePate + "config" + File.separator;
bicProp prop = new bicProp(strFilePate);
int iHostPort = prop.getIntProperty("mail.host.port");
String strHostIP = prop.getProperty("mail.host.ip");
String strSender = prop.getProperty("mail.sender");
String strFrom = prop.getProperty("mail.from");
if(!bicUtil.IsNull(strSender)){
strFrom = "\"" + strSender + "\" <" + strFrom + ">";
}
String strTo = prop.getProperty("mail.to");
String strSubject = prop.getProperty("mail.subject");
String strEncode = prop.getProperty("mail.encode");
System.out.print(".");
if(chrMailType =='0' || chrMailType =='0'){
strSubject = bicUtil.Replace(strSubject,"[DATE]",bicUtil.GetCurrentDate());
}else if(chrMailType == '1'){
strSubject = bicUtil.Replace(strSubject,"[DATE]",bicUtil.GetSpecialDate(0,0,-1));
}else if(chrMailType == '3'){
strSubject = bicUtil.Replace(strSubject,"[DATE]",bicUtil.GetSpecialDate(0,0,-3));
}
System.out.print(".");
String strTextName = prop.getProperty("mail.text");
String strText = "";
bicFile mailText = new bicFile(strFilePate,strTextName);
System.out.print(".");
if(!mailText.exists()){
System.out.println("Error:mail text is not exists.");
return;
}else{
String strLine;
try {
mailText.openReadFile(strEncode);
while((strLine = mailText.readLine()) != null){
System.out.print(".");
strText += strLine + "\r\n";
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
System.out.println(".");
System.out.print("MAIL SENDING");
try {
bicMail mail = new bicMail(strRootFilePate);
if(iHostPort != 0){
mail.setMailPort(iHostPort);
}
if(!bicUtil.IsNull(strHostIP)){
mail.setMailSrvAddr(strHostIP);
}
System.out.print(".");
mail.setEncName(strEncode);
System.out.print(".");
mail.setMailFrom(strFrom);
System.out.print(".");
mail.setMailTo(strTo);
System.out.print(".");
mail.setMailSubject(strSubject);
System.out.print(".");
mail.setMailText(strText);
System.out.print(".");
mail.send();
System.out.println(".");
}
catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("MAIL SEND FINISH,QUIT AUTOMATIC."); } private void AppWait(int iTime){
try {
Thread.sleep(iTime);
}
catch (Exception ex) {
System.out.println("[ERROR]WAIT ERROR.");
}
}
}
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.io.File;public class bicMain {
private static String strRootFilePate = "";
public static void main(String[] args) {
strRootFilePate = bicUtil.GetRootPath();
System.out.println("********************************************************");
System.out.println("BATCH MAIL SENDER (C) 2003-8 1.0.1 YangGuoqing");
System.out.println("");
System.out.println("MODIFY HISTORY");
System.out.println("1.0--1.0.1 : ADD AUTO-DETECT APPLICATION ROOT PATH");
System.out.println(" : CHANGE MAIL TYPE TO 0,1,3,9 FOR SENDING ");
System.out.println(" DIFFERENT SUBJECT MAIL");
System.out.println("********************************************************");
System.out.println("");
char chrMailType = 0;
while(true){
if(chrMailType != 10 && chrMailType != 13){
System.out.println("PLEASE SELECT \"0\" , \"1\" , \"3\" or \"9\" FROM YOUR KEYBOARD");
System.out.println(" 0: MAIL DATE IS [TODAY]");
System.out.println(" 1: MAIL DATE IS [YESTODAY]");
System.out.println(" 3: MAIL DATE IS [LAST WEEKEND]");
System.out.println(" 9: QUIT");
System.out.print("CHOOSE TYPE:");
}
try {
chrMailType = (char)System.in.read();
}
catch (Exception ex) {
System.out.println("[Error:]Can't read from keyboard input.");
ex.printStackTrace();
}
if(chrMailType !='0' && chrMailType !='1' && chrMailType !='3' && chrMailType !='9'){
if(chrMailType != 10 && chrMailType != 13){
System.out.print("KEYBOARD INPUT ERROR["+ chrMailType +"],");
}
}else if(chrMailType == '9'){
System.exit(0);
}else{
break;
}
}
System.out.print("SET MAIL CONFIG");
String strFilePate = strRootFilePate + "config" + File.separator;
bicProp prop = new bicProp(strFilePate);
int iHostPort = prop.getIntProperty("mail.host.port");
String strHostIP = prop.getProperty("mail.host.ip");
String strSender = prop.getProperty("mail.sender");
String strFrom = prop.getProperty("mail.from");
if(!bicUtil.IsNull(strSender)){
strFrom = "\"" + strSender + "\" <" + strFrom + ">";
}
String strTo = prop.getProperty("mail.to");
String strSubject = prop.getProperty("mail.subject");
String strEncode = prop.getProperty("mail.encode");
System.out.print(".");
if(chrMailType =='0' || chrMailType =='0'){
strSubject = bicUtil.Replace(strSubject,"[DATE]",bicUtil.GetCurrentDate());
}else if(chrMailType == '1'){
strSubject = bicUtil.Replace(strSubject,"[DATE]",bicUtil.GetSpecialDate(0,0,-1));
}else if(chrMailType == '3'){
strSubject = bicUtil.Replace(strSubject,"[DATE]",bicUtil.GetSpecialDate(0,0,-3));
}
System.out.print(".");
String strTextName = prop.getProperty("mail.text");
String strText = "";
bicFile mailText = new bicFile(strFilePate,strTextName);
System.out.print(".");
if(!mailText.exists()){
System.out.println("Error:mail text is not exists.");
return;
}else{
String strLine;
try {
mailText.openReadFile(strEncode);
while((strLine = mailText.readLine()) != null){
System.out.print(".");
strText += strLine + "\r\n";
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
System.out.println(".");
System.out.print("MAIL SENDING");
try {
bicMail mail = new bicMail(strRootFilePate);
if(iHostPort != 0){
mail.setMailPort(iHostPort);
}
if(!bicUtil.IsNull(strHostIP)){
mail.setMailSrvAddr(strHostIP);
}
System.out.print(".");
mail.setEncName(strEncode);
System.out.print(".");
mail.setMailFrom(strFrom);
System.out.print(".");
mail.setMailTo(strTo);
System.out.print(".");
mail.setMailSubject(strSubject);
System.out.print(".");
mail.setMailText(strText);
System.out.print(".");
mail.send();
System.out.println(".");
}
catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("MAIL SEND FINISH,QUIT AUTOMATIC."); } private void AppWait(int iTime){
try {
Thread.sleep(iTime);
}
catch (Exception ex) {
System.out.println("[ERROR]WAIT ERROR.");
}
}
}
解决方案 »
- The server encountered an internal error () that prevented it from fulfilling th
- 05的数据导入到mysql 5.0 请教
- java 执行 sql 延迟
- 有谁在软通动力,咋样?
- JSP向SQL添加数据时出现的问题 请大家帮助解决 谢谢
- 急死了,帮忙啊
- 超简单表单自动校验
- 招聘jsp网站程序员(斑竹允许几天,不要删,我们在51job上没有几个人投简历)
- 文本文件的创建、写入、读出....高手请进!!
- 如何在JSP中检测从数据库存取操作的bean中读回的一个空纪录?
- 连接oracle数据库连接池的bean,通是通了,但是还是有问题,高手帮忙看看!
- 关于resultset的问题,散分来了.
n = System.in.read();For above code, if you push 'a' on the keyboard, the value of n is 97 which is the code value of character 'a'.The number one console Java cliche is:BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine(); //string input from keyboardThen, if all the characters in the string 'line' is digit, you can get numerical value using another Java cliche:int n = Integer.parseInt(line);
or
double d = Double.parseDouble(line);
etc.All most all of the above cliches geneate Exceptions. You must try/catch or throws them otherwise you get compiler error.