Java Stream Operation getOSIllegalCharacterStream(String path)

Here you can find the source of getOSIllegalCharacterStream(String path)

Description

get OS Illegal Character Stream

License

Open Source License

Declaration

private static IntStream getOSIllegalCharacterStream(String path) 

Method Source Code

//package com.java2s;
/*//from   ww w . j  a v  a 2s .c  o  m
 * 
 * $Revision: 34120 $ $Date: 2015-12-02 23:16:17 +0100 (Mi, 02 Dez 2015) $
 *
 * This file is part of ***  M y C o R e  ***
 * See http://www.mycore.de/ for details.
 *
 * This program is free software; you can use it, redistribute it
 * and / or modify it under the terms of the GNU General Public License
 * (GPL) as published by the Free Software Foundation; either version 2
 * of the License or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program, in a file called gpl.txt or license.txt.
 * If not, write to the Free Software Foundation Inc.,
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
 */

import java.util.stream.IntStream;

public class Main {
    /**
     * reserved URI characters should not be in uploaded filenames. See RFC3986,
     * Section 2.2
     */
    private static final String reserverdCharacters = new String(
            new char[] { ':', '?', '%', '#', '[', ']', '@', '!', '$', '&',
                    '\'', '(', ')', '*', ',', ';', '=', '\'', '+' });
    private static final String WINDOWS_RESERVED_CHARS = "<>:\"|?*";

    private static IntStream getOSIllegalCharacterStream(String path) {
    //https://msdn.microsoft.com/en-us/library/aa365247.aspx
    return path
        .chars()
        .filter(c -> c < '\u0020' || WINDOWS_RESERVED_CHARS.indexOf(c) != -1 || reserverdCharacters.indexOf(c) != -1);
}
}

Related

  1. findStreamAmongst(Class clazz, Collection instances)
  2. firstValue(Stream stream)
  3. flatOptionals(Stream> list)
  4. flattenFeatureStreamToMap( Stream>>> stream)
  5. gcd(IntStream numbers)
  6. getStream(Iterable iterable)
  7. getStringStreamFromArray(String... ids)
  8. infiniteParallelStream()
  9. interleave(Stream a, Stream b)