Java File Name Sanitize sanitizeFilenameForWindows(String filename)

Here you can find the source of sanitizeFilenameForWindows(String filename)

Description

sanitize Filename For Windows

License

Open Source License

Declaration

static public String sanitizeFilenameForWindows(String filename) 

Method Source Code

//package com.java2s;
/* The MIT License (MIT)
 * Copyright (c) 2014 Nicholas Wright/*ww  w . ja  va2s  .co  m*/
 * http://opensource.org/licenses/MIT
 */

public class Main {
    private static final String[] ILLEGAL_FILENAME_CHARS = { "/", "\\", ":", "?", "\"", "<", ">", "|" };

    static public String sanitizeFilenameForWindows(String filename) {

        String sanitized = filename;

        for (String ic : ILLEGAL_FILENAME_CHARS) {
            sanitized = sanitized.replace(ic, "_");
        }

        return sanitized;
    }
}

Related

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