?? corbamnqreqlogger.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 + -