Java File Name Sanitize sanitize(String fileName)

Here you can find the source of sanitize(String fileName)

Description

sanitize

License

Open Source License

Declaration

public static final String sanitize(String fileName) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String sanitize(String fileName) {
        StringBuffer buffer = new StringBuffer();
        for (char c : fileName.toCharArray()) {
            if (Character.isJavaIdentifierPart(c)) {
                buffer.append(c);//w  ww.  j  a  v  a2 s  .  com
            }
        }
        if (buffer.length() == 0) {
            buffer.append(System.currentTimeMillis());
        }
        return buffer.toString();
    }
}

Related

  1. sanitizeBlankNodeName(String filename)
  2. sanitizeFilename(String filename)
  3. sanitizeFileName(String filename)
  4. sanitizeFileName(String filename)