← 返回首页
Merge pull request #479 from stefanhahmann/file-list-coverters-empty-… · scijava/scijava-common@a2d0042 · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

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

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎src/main/java/org/scijava/convert/FileListConverters.java‎

Lines changed: 2 additions & 0 deletions
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()]);

‎src/test/java/org/scijava/convert/FileListConverterTest.java‎

Lines changed: 1 addition & 0 deletions
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)

Footer

© 2026 GitHub, Inc.