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

📄 corbamnqreqlogger.java

📁 UCS (Ultra Corba Simulator) is one more powerful corba client/servant simulator tool than other simi
💻 JAVA
字号:
package com.corba.mnq.ui;

import com.corba.mnq.main.MNQmainFrame;

import java.io.FileWriter;
import java.io.IOException;

public class CorbaMNQReqLogger {

    private MNQmainFrame client;

    /**
     * Constructor of CorbaMNQReqLogger
     * 
     * @param client
     *            reference to the initiator MNQmainFrame
     */
    public CorbaMNQReqLogger(MNQmainFrame client) {
        this.client = client;
    }

    /**
     * Writes the provided String (loggable) to the provided logFile
     * 
     * @param loggable
     *            the String to write to logfile
     * @throws OperationCannotBeLoggedException
     *             in case the logFile cannot be accessed
     */
    protected void writeToLogFile(String loggable) throws OperationCannotBeLoggedException {
        if (client == null) { throw new OperationCannotBeLoggedException(
                "The client reference is null!"); }
        String logFile = client.getOperationLogFileName();
        if (logFile == null || logFile.equals("")) { throw new OperationCannotBeLoggedException(
                "The operation log filename is null or empty!"); }
        try {
            FileWriter fileWriter = new FileWriter(logFile, true);
            if (fileWriter != null) {
                fileWriter.write(loggable);
                fileWriter.close();
            } else {
                throw new OperationCannotBeLoggedException("The provided file cannot be accessed!");
            }
        } catch (IOException e) {
            throw new OperationCannotBeLoggedException("The provided file cannot be accessed!");
        }
    }

    /**
     * name: "OperationCannotBeLoggedException"
     * 
     * @author ucs_2008
     */
    static class OperationCannotBeLoggedException extends Exception {

        public OperationCannotBeLoggedException(String message) {
            super(message);
        }
    }
}

⌨️ 快捷键说明

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