Java File Name Sanitize sanitizeFilename(String toClean)

Here you can find the source of sanitizeFilename(String toClean)

Description

makes the string a more friendly filesystem path for java.

License

Open Source License

Declaration

public static String sanitizeFilename(String toClean) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//w  w  w  . jav  a2 s.c  om
     * makes the string a more friendly filesystem path for java. this includes turning backslashes into forward slashes.
     */
    public static String sanitizeFilename(String toClean) {
        if (toClean == null)
            return toClean; // can't fix nothing.
        // _logger.debug("before='" + toClean + "'");

        String toReturn = toClean.replace('\\', '/');

        // future: any other cleanings we should do on the path?

        // _logger.debug("after='" + toReturn + "'");
        return toReturn;
    }
}

Related

  1. sanitizeFilename(String name)
  2. sanitizeFileName(String name)
  3. sanitizeFilename(String name)
  4. sanitizeFileName(String name)
  5. sanitizeFileName(String s)
  6. sanitizeFilenameForWindows(String filename)
  7. sanitizeForFileName(final String orig)
  8. sanitizeToValidFilename(String name)