从上图可以看出:
包:
代码: 全选
package IISAnalysis;
代码: 全选
class
Search
class
IIS_Count
代码: 全选
"Search.java" 72L, 2230C 已写入
:!javac Search.java
Search.java:19: 找不到符号
符号: 类 IIS_Count
位置: 类 IISAnalysis.Search
IIS_Count logcount = new IIS_Count();
^
Search.java:19: 找不到符号
符号: 类 IIS_Count
位置: 类 IISAnalysis.Search
IIS_Count logcount = new IIS_Count();
^
2 错误
Shell 已返回1
我的观点是:可能Gvim并没有识别包内的另一个文件IIS_Count类,那么就存在2个问题
1. Gvim是否能识别包内的其他文件并引入呢?如果不识别的话,那我这个程序肯定不行的了,但是别人使用他来编译c代码都可以了
2. 怎么解决上述问题呢?就是如何让我的Gvim能识别包内的其他文件?
源码:
Search.java
代码: 全选
package IISAnalysis;
import java.io.*;
public class Search {
public String get_date(){
return "Date:\t"+this.Date+"\n";
}
public String get_Countall(){
return "Count:\t"+String.valueOf(Count_all)+"\n";
}
/**
* 以行为单位读取文件,常用于读面向行的格式化文件
*/
public static void readFileByLines(String fileName) {
File file = new File(fileName);
BufferedReader reader = null;
IIS_Count logcount = new IIS_Count();
try {
System.out.println("\t以行为单位读取文件内容,一次读一整行:");
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
if(tempString.charAt(0)!='#'){
//System.out.println("line " + line + ": " + tempString);
line++;
}
}
logcount.setVisitNum(line);
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
public static void writeFile(String fileName, Search temp) throws Exception {
try {
//打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
FileWriter writer = new FileWriter(fileName, true);
writer.write(temp.get_date());
writer.write(temp.get_Countall());
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception{
System.out.println("测 试 开 始 --------");
Search test=new Search();
readFileByLines("src/IISAnalysis/iislog");
writeFile("src/IISAnalysis/log_count",test);
System.out.println("\n测 试 结 束 --------");
}
private String Date;
private String Time;
private int Count_all;
private int Count_user;
}
代码: 全选
package IISAnalysis;
import java.util.*;
class IIS_Count {
/**
* 构造器:初始化各属性
*/
IIS_Count(){
this.countReset();
}
/**
* 重置iis各项统计数据为空,以便再次统计日志各项数据
*/
public void countReset(){
this.Log_type = "Null";
this.Date = "Null";
this.Visit_num = 0;
this.status.clear();
}
/**
* 设置日志数据的类型
*/
public void setLogType(String logtype){
this.Log_type = logtype;
}
/**
* 获取日志数据类型的统计结果
*/
public String getLogType(){
return this.Log_type;
}
/**
* 设置日志数据的产生日期
*/
public void setDate(String date){
this.Date = date;
}
/**
* 获取日志数据类型的日期
*/
public String getDate(){
return this.Date;
}
/**
* 通过计数来统计来访人员数目
*/
public void setVisitNum(int visitnum){
this.Visit_num = visitnum;
}
/**
* 获取来访人数的统计结果
*/
public int getVisitNum(){
return this.Visit_num;
}
/**
* 通过计数来统计日志运行的返回类型统计,或者错误统计
*/
public void setStatus(String temp){
String[] data = temp.split(" ");
if( status.containsKey(data[11]) )
status.put(data[11], 1+this.status.get(data[11]));
}
/**
* 获取日志返回类型的的统计结果
*/
public Map<String, Integer> getStatus(){
return this.status;
}
private String Log_type;
private int Visit_num;
private String Date;
private Map<String, Integer> status = new HashMap<String, Integer>();
}