public static String makeSafeFilename(String filename) {
        // Replace invalid characters
        for (final Map.Entry<Pattern, String> pair : REPLACEMENT_PAIRS.entrySet()) {
            final Pattern pattern = pair.getKey();
            final Matcher matcher = pattern.matcher(filename);
            filename = matcher.replaceAll(pair.getValue());
        }

        // Make sure the name doesn't violate a Windows reserved word...
        for (Pattern pattern : WINDOWS_INVALID_PATTERNS) {
            if (pattern.matcher(filename).matches()) {
                filename = "uP-" + filename;
                break;
            }
        }

        return filename;
    }
public static String makeSafeFilename ( String filename ) { for ( final Map . Entry < Pattern , String > pair : REPLACEMENT_PAIRS . entrySet ( ) ) { final Pattern pattern = pair . getKey ( ) ; final Matcher matcher = pattern . matcher ( filename ) ; filename = matcher . replaceAll ( pair . getValue ( ) ) ; } for ( Pattern pattern : WINDOWS_INVALID_PATTERNS ) { if ( pattern . matcher ( filename ) . matches ( ) ) { filename = "uP-" + filename ; break ; } } return filename ; }
Makes 'safe' filename