还要请大家帮忙看一下,为什么我的代码在JDK1.408上可以通过并运行,但在JDK1.5中可以编译,但运行就出错呢?提示
java.lang.NoSuchMethodError
at doAnalyse.analyseString(analyseLogs.java:72)
at doAnalyse.doA(analyseLogs.java:48)
at analyseLogs.run(analyseLogs.java:22)我的代码如下:
import java.io.*;
import java.lang.*;
import java.util.*;
import java.sql.*;
public class analyseLogs extends Thread{
private static int lineNum = 0;
public static void main(String args[]) throws IOException{
Thread go = new analyseLogs();
go.start();
}
public void run(){
doAnalyse da = new doAnalyse();
while(true){
try{
lineNum = da.doA(da.showLogFiles(), lineNum);
}catch(IOException e){
System.out.println(e.toString());
}
try{
Thread.sleep(1000);
}catch(InterruptedException e){
System.err.println(e.toString());
}
}
}
}//----------------------------------------------------
class doAnalyse{
public int doA(String LogFiles , int lineNum) throws IOException {
String Logs = "";
int thisLine = 0;
String strSQL = "";
String login_time = "",logout_time = "";
BufferedReader BR = new BufferedReader(new FileReader(LogFiles));
showTime ST = new showTime();
doSQL DS = new doSQL();
while((Logs = BR.readLine()) != null){
if(!Logs.equals("")){
if(thisLine >= lineNum){
if (analyseString(Logs, "LOGIN")) {
login_time = ST.thisYear + "-" + ST.thisMonth + "-" + ST.thisDate + " " + analyseString(Logs ,0);
strSQL = "insert into act_info (login_time,out_time,user_code,act_type)values('" + login_time + "',''," + analyseString(Logs , 2) + ",0)";
System.out.println(thisLine + " " + strSQL);
DS.mackSQL(strSQL);
}else if(analyseString(Logs , "LOGOUT")){
logout_time = ST.thisYear + "-" + ST.thisMonth + "-" + ST.thisDate + "-" + " "+ analyseString(Logs , 0);
strSQL = "update act_into set out_time = '" + logout_time + "',act_type = 1 where user_code = " + analyseString(Logs , 2);
System.out.println(thisLine + " " + strSQL);
DS.mackSQL(strSQL);
}
}
thisLine ++;
}
}
return thisLine;
}
public String showLogFiles(){
showTime ST = new showTime();
String out = "C:\\bin\\userlogs\\" + ST.thisYear + "-" + ST.thisMonth + "-" + ST.thisDate + ".txt";
return out;
}
public boolean analyseString(String line,String isIn){
boolean bl = false;
List list = Arrays.asList(line.split(" "));
Iterator it = list.iterator();
while(it.hasNext()){
if(((String)it.next()).equals(isIn)){
bl = true;
}
}
return bl;
}
public String analyseString(String line , int isIn){
String out = "";
List list = Arrays.asList(line.split(" "));
out = (String)list.get(isIn);
return out;
}
}
//------------------------------------------------------
class showTime{
public String thisYear = "" , thisMonth = "" , thisDate = "";
public showTime(){
Calendar calendar = Calendar.getInstance();
if(calendar.get(Calendar.YEAR)< 10){
this.thisYear = "0" + String.valueOf(calendar.get(Calendar.YEAR));
}else{
this.thisYear = String.valueOf(calendar.get(Calendar.YEAR));
}
if(calendar.get(Calendar.MONTH) + 1 < 10){
this.thisMonth = "0" + String.valueOf(calendar.get(Calendar.MONTH) + 1);
}else{
this.thisMonth = String.valueOf(calendar.get(Calendar.MONTH) + 1);
}
if(calendar.get(Calendar.DATE) < 10){
this.thisDate = "0" + String.valueOf(calendar.get(Calendar.DATE));
}else{
this.thisDate = String.valueOf(calendar.get(Calendar.DATE));
}
}
}
//-------------------------------------------------------
class doSQL{
public void mackSQL(String strSQL){
/*String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:soliao";
String userId ="sa";
String userPass ="zjf"; Connection conn = null;
try{
ResultSet rs = null;
Class.forName(sDBDriver);
conn = DriverManager.getConnection(sConnStr, userId, userPass);
Statement stmt=conn.createStatement();
stmt.executeQuery(strSQL);
}catch(Exception e){
//System.err.println(e);
}*/ }
}
java.lang.NoSuchMethodError
at doAnalyse.analyseString(analyseLogs.java:72)
at doAnalyse.doA(analyseLogs.java:48)
at analyseLogs.run(analyseLogs.java:22)我的代码如下:
import java.io.*;
import java.lang.*;
import java.util.*;
import java.sql.*;
public class analyseLogs extends Thread{
private static int lineNum = 0;
public static void main(String args[]) throws IOException{
Thread go = new analyseLogs();
go.start();
}
public void run(){
doAnalyse da = new doAnalyse();
while(true){
try{
lineNum = da.doA(da.showLogFiles(), lineNum);
}catch(IOException e){
System.out.println(e.toString());
}
try{
Thread.sleep(1000);
}catch(InterruptedException e){
System.err.println(e.toString());
}
}
}
}//----------------------------------------------------
class doAnalyse{
public int doA(String LogFiles , int lineNum) throws IOException {
String Logs = "";
int thisLine = 0;
String strSQL = "";
String login_time = "",logout_time = "";
BufferedReader BR = new BufferedReader(new FileReader(LogFiles));
showTime ST = new showTime();
doSQL DS = new doSQL();
while((Logs = BR.readLine()) != null){
if(!Logs.equals("")){
if(thisLine >= lineNum){
if (analyseString(Logs, "LOGIN")) {
login_time = ST.thisYear + "-" + ST.thisMonth + "-" + ST.thisDate + " " + analyseString(Logs ,0);
strSQL = "insert into act_info (login_time,out_time,user_code,act_type)values('" + login_time + "',''," + analyseString(Logs , 2) + ",0)";
System.out.println(thisLine + " " + strSQL);
DS.mackSQL(strSQL);
}else if(analyseString(Logs , "LOGOUT")){
logout_time = ST.thisYear + "-" + ST.thisMonth + "-" + ST.thisDate + "-" + " "+ analyseString(Logs , 0);
strSQL = "update act_into set out_time = '" + logout_time + "',act_type = 1 where user_code = " + analyseString(Logs , 2);
System.out.println(thisLine + " " + strSQL);
DS.mackSQL(strSQL);
}
}
thisLine ++;
}
}
return thisLine;
}
public String showLogFiles(){
showTime ST = new showTime();
String out = "C:\\bin\\userlogs\\" + ST.thisYear + "-" + ST.thisMonth + "-" + ST.thisDate + ".txt";
return out;
}
public boolean analyseString(String line,String isIn){
boolean bl = false;
List list = Arrays.asList(line.split(" "));
Iterator it = list.iterator();
while(it.hasNext()){
if(((String)it.next()).equals(isIn)){
bl = true;
}
}
return bl;
}
public String analyseString(String line , int isIn){
String out = "";
List list = Arrays.asList(line.split(" "));
out = (String)list.get(isIn);
return out;
}
}
//------------------------------------------------------
class showTime{
public String thisYear = "" , thisMonth = "" , thisDate = "";
public showTime(){
Calendar calendar = Calendar.getInstance();
if(calendar.get(Calendar.YEAR)< 10){
this.thisYear = "0" + String.valueOf(calendar.get(Calendar.YEAR));
}else{
this.thisYear = String.valueOf(calendar.get(Calendar.YEAR));
}
if(calendar.get(Calendar.MONTH) + 1 < 10){
this.thisMonth = "0" + String.valueOf(calendar.get(Calendar.MONTH) + 1);
}else{
this.thisMonth = String.valueOf(calendar.get(Calendar.MONTH) + 1);
}
if(calendar.get(Calendar.DATE) < 10){
this.thisDate = "0" + String.valueOf(calendar.get(Calendar.DATE));
}else{
this.thisDate = String.valueOf(calendar.get(Calendar.DATE));
}
}
}
//-------------------------------------------------------
class doSQL{
public void mackSQL(String strSQL){
/*String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:soliao";
String userId ="sa";
String userPass ="zjf"; Connection conn = null;
try{
ResultSet rs = null;
Class.forName(sDBDriver);
conn = DriverManager.getConnection(sConnStr, userId, userPass);
Statement stmt=conn.createStatement();
stmt.executeQuery(strSQL);
}catch(Exception e){
//System.err.println(e);
}*/ }
}
at doAnalyse.analyseString(analyseLogs.java:72)
at doAnalyse.doA(analyseLogs.java:48)
at analyseLogs.run(analyseLogs.java:22)这个提示是什么意思啊?在这几个方法里有错误吗?
-------------
你自己看看吧.在哪里都是通不过的.方法签名不对应,所以提示没有这样的方法错误NoSuchMethodError