Skip to content

Commit

Permalink
resolved style checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Goutam Lavudiya committed Mar 25, 2020
1 parent 7d0bcd7 commit 10ee0ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/main/java/org/jabref/logic/util/io/FileNameHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ public static String getNonOverWritingFileName(Path targetDirectory, String file
String extensionSuffix = "";
String fileNameWithoutExtension = fileName;

if(extensionOptional.isPresent()) {
extensionSuffix = '.'+extensionOptional.get();
if (extensionOptional.isPresent()) {
extensionSuffix = '.' + extensionOptional.get();
fileNameWithoutExtension = fileName.substring(0, fileName.lastIndexOf('.'));
}

Path absolutePath = Paths.get(absoluteName);
String newFileName = fileName;

for(int counter = 1; Files.exists(absolutePath); ++counter) {
newFileName = fileNameWithoutExtension+" ("+counter+")"+extensionSuffix;
for (int counter = 1; Files.exists(absolutePath); ++counter) {
newFileName = fileNameWithoutExtension +
" (" + counter + ")" +
extensionSuffix;
absolutePath = targetDirectory.resolve(newFileName);
}
return newFileName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.jabref.logic.util.io;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class FileNameHandlerTest {
Expand Down

0 comments on commit 10ee0ef

Please sign in to comment.