private static String escapeFileSeparatorChar ( String fname ) { if ( File . separatorChar == ' ' ) { return fname . replaceAll ( File . separator + File . separator , "_" ) ; } else { return fname . replaceAll ( File . separator , "_" ) ; } }
Escape file separator char to underscore . This prevents the file name from using file path separator .