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

📄 mailclientui.java

📁 自己编写的邮件管理系统程序源代码,方便管理自己的邮件
💻 JAVA
字号:
package mail.ui;import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.io.RandomAccessFile;import java.text.SimpleDateFormat;import java.util.Date;public class MailClientUI {    /**     * 日志记录,记录一些客户访问信息     */    private RandomAccessFile infoLog = null;    /**     * 日志记录,记录错误信息     */    private RandomAccessFile errorLog = null;        private String emailName= null;    private String emailPsw= null;    private String smtpServer= null;    private String pop3Server= null;        private MailDisplayUI displayUI=null;    private MailReceiveUI receiveUI=null;    private MailSendUI sendUI=null;    private UserAccountSetUI accountUI=null;        public MailClientUI()    {        initFileSystem();            }    private void initUISystem()    {        displayUI=new MailDisplayUI(this);        receiveUI=new MailReceiveUI(this);        sendUI=new MailSendUI(this);        accountUI=new UserAccountSetUI(this);                accountUI.setVisibleTrue();    }    public static void main(String[] args)    {        new MailClientUI();    }    /**     * 读取文件 获取服务路径 并对日志文件进行初始化     */    private void initFileSystem()    {        try        {            //获取当前路径            File nowdir = new File(".").getAbsoluteFile();            String dirString = nowdir.toString();            String subs = dirString.substring(0, dirString.length() - 1);            File fileInfo = new File(subs + "info/");            if (!fileInfo.exists())                fileInfo.mkdir();            //打开记录客户服务的日志文件            File logFile = new File(fileInfo, "server.log");            infoLog = new RandomAccessFile(logFile, "rw");            infoLog.seek(infoLog.length());            //打开记录错误信息的日志文件            File errorFile = new File(fileInfo, "error.log");            errorLog = new RandomAccessFile(errorFile, "rw");            errorLog.seek(errorLog.length());            File serverInfo = new File(fileInfo, "mail.ini");            FileReader fr = new FileReader(serverInfo);            BufferedReader br = new BufferedReader(fr);            emailName= br.readLine();            emailPsw= br.readLine();            smtpServer= br.readLine();            pop3Server= br.readLine();            fr.close();            br.close();            initUISystem();        } catch (FileNotFoundException fnfe)        {            errorLog("无法找到文件:" + fnfe.getMessage());            System.exit(0);        } catch (IOException ioe)        {            errorLog("打开文件过程中发生IO错误:" + ioe.getMessage());            System.exit(0);        } catch (Exception e)        {            errorLog("非预知错误:" + e.getMessage());            System.exit(0);        }    }    /**     * 记录信息     *      * @param info     */    public void log(String info)    {        try        {            if (infoLog != null)            {                Date today = new Date();                //格式化日期                SimpleDateFormat formatter = new SimpleDateFormat("20yy:MM:dd hh:mm: ");                String dateString = formatter.format(today);                //输出信息到文件                infoLog.write((dateString + info).getBytes());                infoLog.writeByte(13);                infoLog.writeByte(10);            }        } catch (Exception e)        {            e.printStackTrace();            errorLog(e.getMessage());        }    }    /**     * 提供错误日志记录     *      * @param errorInfo     */    public synchronized void errorLog(String errorInfo)    {        try        {            if (errorLog != null)            {                Date today = new Date();              // 格式化日期                SimpleDateFormat formatter = new SimpleDateFormat("20yy:MM:dd hh:mm: ");                String dateString = formatter.format(today);               //输出信息到文件                String s = (dateString + ":" + errorInfo);                errorLog.write(s.getBytes());                errorLog.writeByte(13);                errorLog.writeByte(10);            }        } catch (Exception e)        {            e.printStackTrace();        }    }        public String getEmailName()    {        return emailName;    }    public void setEmailName(String emailName)    {        this.emailName = emailName;    }    public String getEmailPsw()    {        return emailPsw;    }    public void setEmailPsw(String emailPsw)    {        this.emailPsw = emailPsw;    }    public String getPop3Server()    {        return pop3Server;    }    public void setPop3Server(String pop3Server)    {        this.pop3Server = pop3Server;    }    public String getSmtpServer()    {        return smtpServer;    }    public void setSmtpServer(String smtpServer)    {        this.smtpServer = smtpServer;    }        public UserAccountSetUI getAccountUI()    {        return accountUI;    }    public void setAccountUI(UserAccountSetUI accountUI)    {        this.accountUI = accountUI;    }    public MailDisplayUI getDisplayUI()    {        return displayUI;    }    public void setDisplayUI(MailDisplayUI displayUI)    {        this.displayUI = displayUI;    }    public MailReceiveUI getReceiveUI()    {        return receiveUI;    }    public void setReceiveUI(MailReceiveUI receiveUI)    {        this.receiveUI = receiveUI;    }    public MailSendUI getSendUI()    {        return sendUI;    }    public void setSendUI(MailSendUI sendUI)    {        this.sendUI = sendUI;    }}

⌨️ 快捷键说明

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