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

📄 daofromfile.java

📁 航空定票系统:户端功能模块:用户登录模块
💻 JAVA
字号:
package com.tarena.abs.dao;

import java.util.*;
import java.io.*;
import com.tarena.abs.model.*;
import com.tarena.abs.util.*;

public class DAOFromFile implements DAOInterface{
	File userFile;
	File schedularFile;
	File flightFile;
	public DAOFromFile(Properties p) throws FileNotFoundException{
		userFile=new File(p.getProperty("UserFileName"));
		schedularFile=new File(p.getProperty("SchedularFileName"));
		flightFile=new File(p.getProperty("FlightFileName"));
		if(!userFile.exists() || !schedularFile.exists() || !flightFile.exists()){
			throw new FileNotFoundException("系统信息文件未找到");
		}
	}

	public boolean addSchedular(FlightSchedular fs) {
		FileOutputStream fos=null;
		OutputStreamWriter osw=null;
		PrintWriter pw=null;
		FileInputStream fis=null;
		InputStreamReader isr=null;
		BufferedReader br=null;
		try {
			fis=new FileInputStream(schedularFile);
			isr=new InputStreamReader(fis);
			br=new BufferedReader(isr);
			String str=null;
			while((str=br.readLine())!=null){
				if(Parse.parseSchedular(str).equals(fs))
					return false;
			}
		}catch(IOException e){
			e.printStackTrace();
			return false;
		}finally{
			if(br!=null)try{br.close();}catch(IOException e){}
			if(isr!=null)try{isr.close();}catch(IOException e){}
			if(fis!=null)try{fis.close();}catch(IOException e){}
		}
		try{
			fos=new FileOutputStream(schedularFile);
			osw=new OutputStreamWriter(fos);
			pw=new PrintWriter(osw);
			
			StringBuffer sb=new StringBuffer();
			sb.append(fs.getNumber()+",");
			sb.append(fs.getFromAdd()+",");
			sb.append(fs.getStartDate().simpleString()+",");
			sb.append(fs.getEndDate().simpleString()+",");
			sb.append(fs.getFromTime().toString()+",");
			sb.append(fs.getToTime().toString()+",");
			sb.append(fs.getLength()+",");
			sb.append(fs.getTotalPrice()+",");
			sb.append(fs.getPlane()+",");
			String sche=Integer.toString(fs.getSchedular(),2);
			sb.append(sche.substring(sche.length()-8));
			pw.println(sb.toString());
			pw.flush();
			return true;		
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return false;
		}finally{
			if(pw!=null)pw.close();
			if(osw!=null)try{osw.close();}catch(IOException e){}
			if(fos!=null)try{fos.close();}catch(IOException e){}	
		}
	}

	public boolean addUser(User u) {
		// TODO Auto-generated method stub
		return false;
	}

	public Collection getAllFlight(String fromAddress, String toAddress, MyDate date) {
		// TODO Auto-generated method stub
		return null;
	}

	public Collection getAllSchedular(String fromAddress, String toAddress) {
		// TODO Auto-generated method stub
		return null;
	}

	public FlightSchedular getSchedular(String number) {
		// TODO Auto-generated method stub
		return null;
	}

	public User getUser(String name, String password) {
		return new User("tony","430724197912031610",5000,"tangliang@tarena.com.cn");
		//return null;
	}

	public void manager() {
		// TODO Auto-generated method stub
		
	}

	public int order(String number, MyDate date) {
		// TODO Auto-generated method stub
		return 0;
	}

	public boolean removeSchedular(String flightNumber) {
		// TODO Auto-generated method stub
		return false;
	}
	public Collection getAllPlane(){
		return null;
	}

	public boolean addPlaneModel(PlaneModel pm) {
		// TODO Auto-generated method stub
		return false;
	}

	public void dataUpdate() {
		// TODO Auto-generated method stub
		
	}

	public boolean removePlaneModel(String model) {
		// TODO Auto-generated method stub
		return false;
	}
	
}

⌨️ 快捷键说明

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