Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-555

Add a FileSystem enum to provide legal file names

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Reopened
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2.7
    • Component/s: None
    • Labels:
      None

      Description

      Add org.apache.commons.io.FilenameUtils.isIllegalWindowsFileName(char).

          /**
           * Checks whether the given character is illegal in a Windows file names.
           * <p>
           * The illegal character are:
           * </p>
           * <ul>
           * <li>< (less than</li>
           * <li>> (greater than</li>
           * <li>: (colon</li>
           * <li>" (double quote</li>
           * <li>/ (forward slash</li>
           * <li>\ (backslash</li>
           * <li>| (vertical bar or pipe</li>
           * <li>? (question mark</li>
           * <li>* (asterisk</li>
           * <li>ASCII NUL (0)</li>
           * <li>Integer characters 1 through 31</li>
           * <li>There may be other characters that the file name does not allow. Please see
           * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx">Naming Files, Paths,
           * and Namespaces</a></li>
           * </ul>
           * 
           * @see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx">Naming Files,
           *      Paths, and Namespaces</a>
           * @param c
           *            the character to check
           * @return whether the give character is legal
           * @since 2.7
           */
      

      I use this method as a building block to create file names based on Strings from other sources.

      A further contribution could be: String toLegalWindowsFileName(String input, char replacementChar)

        Attachments

          Activity

            People

            • Assignee:
              ggregory Gary D. Gregory
              Reporter:
              ggregory Gary D. Gregory
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: