[Arakhnę-Dev] [317] * FileSystem.replaceExtenstion(File, String): the "." should be append to the replied filename event if it is not inside the given filename nor extension as parameter . |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
- To: dev@xxxxxxxxxxx
- Subject: [Arakhnę-Dev] [317] * FileSystem.replaceExtenstion(File, String): the "." should be append to the replied filename event if it is not inside the given filename nor extension as parameter .
- From: subversion@xxxxxxxxxxxxx
- Date: Mon, 14 Nov 2011 17:41:10 +0100
Revision: 317
Author: galland
Date: 2011-11-14 17:41:10 +0100 (Mon, 14 Nov 2011)
Log Message:
-----------
* FileSystem.replaceExtenstion(File, String): the "." should be append to the replied filename event if it is not inside the given filename nor extension as parameter.
Modified Paths:
--------------
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2011-11-05 13:31:42 UTC (rev 316)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2011-11-14 16:41:10 UTC (rev 317)
@@ -1002,8 +1002,17 @@
File dir = filename.getParentFile();
String name = filename.getName();
int idx = name.lastIndexOf(getFileExtensionCharacter());
- if (idx<0) return new File(dir, name+extension);
- return new File(dir, name.substring(0,idx)+extension);
+ StringBuffer n = new StringBuffer();
+ if (idx<0) {
+ n.append(name);
+ }
+ else {
+ n.append(name.substring(0,idx));
+ }
+ if (!name.endsWith(EXTENSION_SEPARATOR) && !extension.startsWith(EXTENSION_SEPARATOR))
+ n.append(EXTENSION_SEPARATOR);
+ n.append(extension);
+ return new File(dir, n.toString());
}
/** Replace the extension of the specified filename by the given extension.