mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
* Fixing issue #353 Moved replaceIllegalCharacters method into StringUtils. Modified classes that write out to disk to call this method when saving a file. * Implementing suggested changes from comments in PR #448
This commit is contained in:
@@ -20,6 +20,9 @@ package io.github.dsheirer.util;
|
||||
|
||||
public class StringUtils
|
||||
{
|
||||
private static final String[] ILLEGAL_FILENAME_CHARACTERS = {"#", "%", "&", "{", "}", "\\", "<", ">",
|
||||
"*", "?", "/", " ", "$", "!", "'", "\"", ":", "@", "+", "`", "|", "="};
|
||||
|
||||
/**
|
||||
* Compares string a to b and returns true if a is non-null and non-empty, b is non-null and non-empty, and
|
||||
* a is equal to b.
|
||||
@@ -38,4 +41,15 @@ public class StringUtils
|
||||
{
|
||||
return a == null || a.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces any illegal filename characters in the proposed filename
|
||||
*/
|
||||
public static String replaceIllegalCharacters(String filename) {
|
||||
for (String illegalCharacter : ILLEGAL_FILENAME_CHARACTERS) {
|
||||
filename = filename.replace(illegalCharacter, "_");
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user