You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ce...@apache.org on 2004/06/04 00:49:13 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/rolling/helpers Util.java
ceki 2004/06/03 15:49:13
Modified: src/java/org/apache/log4j/rolling/helpers Util.java
Log:
Indentation only
Revision Changes Path
1.4 +27 -25 logging-log4j/src/java/org/apache/log4j/rolling/helpers/Util.java
Index: Util.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/helpers/Util.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Util.java 31 May 2004 21:29:15 -0000 1.3
+++ Util.java 3 Jun 2004 22:49:13 -0000 1.4
@@ -25,18 +25,18 @@
import java.io.FileOutputStream;
import java.io.IOException;
-
/**
* @author Ceki
- *
+ *
*/
public class Util {
+
static Logger logger = Logger.getLogger(Util.class);
public static void rename(String from, String to) throws RolloverFailure {
File fromFile = new File(from);
boolean success = false;
-
+
if (fromFile.exists()) {
File toFile = new File(to);
logger.debug("Renaming file [" + fromFile + "] to [" + toFile + "]");
@@ -44,38 +44,40 @@
boolean result = fromFile.renameTo(toFile);
if (!result) {
- String msg1 = "Failed to rename file [" + fromFile + "] to [" + toFile + "].";
+ String msg1 = "Failed to rename file [" + fromFile + "] to [" + toFile
+ + "].";
LogLog.warn(msg1);
LogLog.warn("Attemting to rename by copying.");
renameByCopying(from, to);
}
} else {
- throw new RolloverFailure("File ["+from+"] does not exist.");
+ throw new RolloverFailure("File [" + from + "] does not exist.");
}
}
-
- public static void renameByCopying(String from, String to) throws RolloverFailure {
+
+ public static void renameByCopying(String from, String to)
+ throws RolloverFailure {
try {
- FileInputStream fis = new FileInputStream(from);
- FileOutputStream fos = new FileOutputStream(to);
- byte[] inbuf = new byte[8102];
- int n;
-
- while ((n = fis.read(inbuf)) != -1) {
- fos.write(inbuf, 0, n);
- }
-
- fis.close();
- fos.close();
-
- File fromFile = new File(from);
-
- if (!fromFile.delete()) {
- logger.warn("Could not delete [" + from + "].");
- }
+ FileInputStream fis = new FileInputStream(from);
+ FileOutputStream fos = new FileOutputStream(to);
+ byte[] inbuf = new byte[8102];
+ int n;
+
+ while ((n = fis.read(inbuf)) != -1) {
+ fos.write(inbuf, 0, n);
+ }
+
+ fis.close();
+ fos.close();
+
+ File fromFile = new File(from);
+
+ if (!fromFile.delete()) {
+ logger.warn("Could not delete [" + from + "].");
+ }
} catch (IOException ioe) {
LogLog.error("Failed to rename file by copying", ioe);
throw new RolloverFailure("Failed to rename file by copying");
}
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org