Java File Name Sanitize sanitizeFilename(String name)

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

Description

Replace forbidden characters with "_" in a filename.

License

Open Source License

Parameter

Parameter Description
name the string to sanitized.

Return

sanitized string.

Declaration

private static String sanitizeFilename(String name) 

Method Source Code

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

public class Main {
    /**/* w  ww . j  av  a2  s  .  com*/
     * Replace forbidden characters with "_" in a filename.
     * 
     * @param name
     *            the string to sanitized.
     * @return sanitized string.
     */
    private static String sanitizeFilename(String name) {
        return name.replaceAll("[:\\\\/*?|<>]", "_");
    }
}

Related

  1. sanitizeFileName(String filename)
  2. sanitizeFilename(String filename)
  3. sanitizeFilename(String fileName)
  4. sanitizeFileName(String filename)
  5. sanitizeFileName(String name)
  6. sanitizeFilename(String name)
  7. sanitizeFileName(String name)
  8. sanitizeFileName(String s)
  9. sanitizeFilename(String toClean)