|
|
@@ -21,6 +21,8 @@ import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URI;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
|
|
|
public class ImageUtil {
|
|
|
|
|
|
@@ -43,9 +45,31 @@ public class ImageUtil {
|
|
|
//sourceFile.get
|
|
|
String routedPath = "";
|
|
|
if(file_name==null) {
|
|
|
- String path = sourceFile.getPath();
|
|
|
+// String path = sourceFile.getPath();
|
|
|
|
|
|
- routedPath=path.replace(".jpg", "_routed.jpg");
|
|
|
+ String name = sourceFile.getName();
|
|
|
+
|
|
|
+ if (name.contains(".")) {
|
|
|
+ String[] nameComponents = name.split("\\.");
|
|
|
+ nameComponents[nameComponents.length - 2] = nameComponents[nameComponents.length - 2] + "_routed";
|
|
|
+
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ for (int i = 0; i < nameComponents.length; i++) {
|
|
|
+
|
|
|
+ String component = nameComponents[i];
|
|
|
+ builder.append(component);
|
|
|
+ if (i != nameComponents.length - 1) {
|
|
|
+ builder.append(".");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ name = builder.toString();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ name = name + "_routed";
|
|
|
+ }
|
|
|
+
|
|
|
+// routedPath=path.replace(".jpg", "_routed.jpg");
|
|
|
+ routedPath = new File(sourceFile.getParent(), name).getAbsolutePath();
|
|
|
}
|
|
|
else
|
|
|
{
|