⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logreader.java

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JAVA
字号:
package cn.jsprun.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class LogReader {
	@SuppressWarnings("unchecked")
	private static List readLog(FileInputStream filereader) {
		List list = new ArrayList();
		BufferedReader br = null;
		InputStreamReader ir=null;
		try {
			ir = new InputStreamReader(filereader,JspRunConfig.charset);
			br = new BufferedReader(ir);
			String newline = br.readLine();
			while (newline != null) {
				list.add(newline);
				newline = br.readLine();
			}

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {				
					br.close();	
					ir.close();
					if (filereader != null) {
						filereader.close();
					}
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	public static List readMedalsLog(String path) {
		List list = new ArrayList();
		Calendar calendar=Common.getGMTCalendar();
		String mouth = "";
		int calemouth = calendar.get(Calendar.MONTH) + 1;
		if (calemouth < 10) {
			mouth = "0" + calemouth;
		} else {
			mouth = "" + calemouth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + mouth + "_medalslog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath);
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String mouthup = "";
		int calemouthup = calendar.get(Calendar.MONTH);
		if (calemouthup < 10) {
			mouthup = "0" + calemouthup;
		} else {
			mouthup = "" + calemouthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + mouthup
				+ "_medalslog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	public static List readRatelog(String path) {
		List list = new ArrayList();
		Calendar calendar = Calendar.getInstance();
		String mouth = "";
		int calemouth = calendar.get(Calendar.MONTH) + 1;
		if (calemouth < 10) {
			mouth = "0" + calemouth;
		} else {
			mouth = "" + calemouth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + mouth
				+ "_ratelog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath);
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String mouthup = "";
		int calemouthup = calendar.get(Calendar.MONTH);
		if (calemouthup < 10) {
			mouthup = "0" + calemouthup;
		} else {
			mouthup = "" + calemouthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + mouthup
				+ "_ratelog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	public static List readBanLog(String path) {
		List list = new ArrayList();
		Calendar calendar = Calendar.getInstance();
		String mouth = "";
		int calemouth = calendar.get(Calendar.MONTH) + 1;
		if (calemouth < 10) {
			mouth = "0" + calemouth;
		} else {
			mouth = "" + calemouth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + mouth
				+ "_banlog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath);
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String mouthup = "";
		int calemouthup = calendar.get(Calendar.MONTH);
		if (calemouthup < 10) {
			mouthup = "0" + calemouthup;
		} else {
			mouthup = "" + calemouthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + mouthup
				+ "_banlog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);  
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
	
	public static List readIllegalLog(String path) {
		List list = new ArrayList();
		Calendar calendar = Calendar.getInstance();
		String mouth = "";
		int calemouth = calendar.get(Calendar.MONTH) + 1;
		if (calemouth < 10) {
			mouth = "0" + calemouth;
		} else {
			mouth = "" + calemouth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + mouth
				+ "_illegallog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath); 
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String mouthup = "";
		int calemouthup = calendar.get(Calendar.MONTH);
		if (calemouthup < 10) {
			mouthup = "0" + calemouthup;
		} else {
			mouthup = "" + calemouthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + mouthup
				+ "_illegallog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);  
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
	public static List readCpLog(String path) {
		List list = new ArrayList();
		Calendar calendar = Calendar.getInstance();
		String mouth = "";
		int calemouth = calendar.get(Calendar.MONTH) + 1;
		if (calemouth < 10) {
			mouth = "0" + calemouth;
		} else {
			mouth = "" + calemouth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + mouth
				+ "_cplog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath);  
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String mouthup = "";
		int calemouthup = calendar.get(Calendar.MONTH);
		if (calemouthup < 10) {
			mouthup = "0" + calemouthup;
		} else {
			mouthup = "" + calemouthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + mouthup
				+ "_cplog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);  
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
	
	public static List readModsLog(String path) {
		List list = new ArrayList();
		Calendar calendar = Calendar.getInstance();
		String month = "";
		int calemonth = calendar.get(Calendar.MONTH) + 1;
		if (calemonth < 10) {
			month = "0" + calemonth;
		} else {
			month = "" + calemonth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + month+ "_modslog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath);  
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String monthup = "";
		int calemonthup = calendar.get(Calendar.MONTH);
		if (calemonthup < 10) {
			monthup = "0" + calemonthup;
		} else {
			monthup = "" + calemonthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + monthup+ "_modslog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);  
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
	
	public static List readErrorLog(String path) {
		List list = new ArrayList();
		Calendar calendar = Calendar.getInstance();
		String mouth = "";
		int calemouth = calendar.get(Calendar.MONTH) + 1;
		if (calemouth < 10) {
			mouth = "0" + calemouth;
		} else {
			mouth = "" + calemouth;
		}
		String nowpath = path + "/" + calendar.get(Calendar.YEAR) + mouth
				+ "_errorlog.jsp";
		File f = new File(nowpath);
		if (f.exists()) {
			try {
				FileInputStream fr = new FileInputStream(nowpath);  
				List nowtime = readLog(fr);
				list.add(nowtime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		String mouthup = "";
		int calemouthup = calendar.get(Calendar.MONTH);
		if (calemouthup < 10) {
			mouthup = "0" + calemouthup;
		} else {
			mouthup = "" + calemouthup;
		}
		String uppath = path + "/" + calendar.get(Calendar.YEAR) + mouthup
				+ "_errorlog.jsp";
		File upf = new File(uppath);
		if (upf.exists()) {
			try {
				FileInputStream fr = new FileInputStream(uppath);  
				List uptime = readLog(fr);
				list.add(uptime);
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -