Skip to content

Commit a2d0042

Browse files
authored
Merge pull request #479 from stefanhahmann/file-list-coverters-empty-input
Ignore empty Strings during String to FileArray conversion
2 parents 37abc7e + 8dc4c0e commit a2d0042

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: src/main/java/org/scijava/convert/FileListConverters.java

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public <T> T convert(final Object src, final Class<T> dest) {
8282
final String[] tokens = StringUtils.splitUnquoted((String) src, ",");
8383
final List<File> fileList = new ArrayList<>();
8484
for (final String filePath : tokens) {
85+
if ( filePath.isEmpty() )
86+
continue;
8587
fileList.add(new File(filePath.replaceAll("^\"|\"$", "")));
8688
}
8789
return (T) fileList.toArray(new File[fileList.size()]);

Diff for: src/test/java/org/scijava/convert/FileListConverterTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void testStringToFileArrayConverter() {
6969
conv.convert(path, File[].class)[0]);
7070
assertEquals("Wrong file name", new File("C:\\temp"),
7171
conv.convert(path, File[].class)[1]);
72+
assertEquals( 0, conv.convert( "", File[].class ).length );
7273
}
7374

7475
@Test

0 commit comments

Comments
 (0)