*/
static String ftpLog = "D:\\Kron\\logs\\ftpLog.log";
int count = 0;
/*
* Routine to delete requested
file from FTP server. 2 Aug 2005 cez
*
*/
public static void doFTPLog(
final String thisMessage )
throws IOException {
StringBuffer realOutBuffer =
new StringBuffer( 1000 );
final Date Now = new Date(
);
/*
* First, verify that the
log file directory is valid
*
* We create a file handle
for the log file location
*/
File filePath = new File(
ftpLog );
/*
* Now, we extract the
directory path from the log file location
*/
File parentDir =
filePath.getParentFile( );
boolean exists =
parentDir.exists( );
/*
* if the directory does not
exist, then use the application's directory.
*/
final File finalPathLocation;
if ( exists ) {
finalPathLocation =
filePath;
} else {
finalPathLocation = new
File (System.getProperty( "user.dir" ) +
filePath.getName(
));
realOutBuffer.append(
"\n??? Log File Path Does Not Exist: " + ftpLog );
realOutBuffer.append(
"\n??? Log File Saved to: " + finalPathLocation.getAbsolutePath() );
ftpLog =
finalPathLocation.getCanonicalPath();
}
FileWriter fw = new
FileWriter( finalPathLocation, true );
try {
realOutBuffer.append(
"\n*** " + Now );
realOutBuffer.append(
"\n*** " + thisMessage );
fw.write(
realOutBuffer.toString( ) );
} catch ( IOException e ) {
} finally {
// please, always write
out the general log, even if an exception
// occurs .....
fw.close( );
}
}