// Path: src/main/java/org/apache/commons/fileupload2/InvalidFileNameException.java
// public class InvalidFileNameException extends RuntimeException {
// 
//     /**
//      * Serial version UID, being used, if the exception
//      * is serialized.
//      */
//     private static final long serialVersionUID = 7922042602454350470L;
// 
//     /**
//      * The file name causing the exception.
//      */
//     private final String name;
// 
//     /**
//      * Creates a new instance.
//      *
//      * @param pName The file name causing the exception.
//      * @param pMessage A human readable error message.
//      */
//     public InvalidFileNameException(final String pName, final String pMessage) {
//         super(pMessage);
//         name = pName;
//     }
// 
//     /**
//      * Returns the invalid file name.
//      *
//      * @return the invalid file name.
//      */
//     public String getName() {
//         return name;
//     }
// 
// }


import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.fileupload2.InvalidFileNameException;
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        copy(inputStream, baos, true);
        return baos.toString(encoding);
    }

    /**
     * Checks, whether the given file name is valid in the sense,
     * that it doesn't contain any NUL characters. If the file name
     * is valid, it will be returned without any modifications. Otherwise,
     * an {@link InvalidFileNameException} is raised.
     *
     * @param fileName The file name to check
     * @return Unmodified file name, if valid.
     * @throws InvalidFileNameException The file name was found to be invalid.
     */
    public static String checkFileName(final String fileName) {
        if (fileName != null  &&  fileName.indexOf('\u0000') != -1) {
            // pFileName.replace("\u0000", "\\0")
            final StringBuilder sb = new StringBuilder();
            for (int i = 0;  i < fileName.length();  i++) {
                final char c = fileName.charAt(i);
                switch (c) {
                    case 0:
                        sb.append("\\0");
                        break;
                    default:
                        sb.append(c);
                        break;
                }
            }
// Path: src/main/java/org/apache/commons/fileupload2/InvalidFileNameException.java
// public class InvalidFileNameException extends RuntimeException {
// 
//     /**
//      * Serial version UID, being used, if the exception
//      * is serialized.
//      */
//     private static final long serialVersionUID = 7922042602454350470L;
// 
//     /**
//      * The file name causing the exception.
//      */
//     private final String name;
// 
//     /**
//      * Creates a new instance.
//      *
//      * @param pName The file name causing the exception.
//      * @param pMessage A human readable error message.
//      */
//     public InvalidFileNameException(final String pName, final String pMessage) {
//         super(pMessage);
//         name = pName;
//     }
// 
//     /**
//      * Returns the invalid file name.
//      *
//      * @return the invalid file name.
//      */
//     public String getName() {
//         return name;
//     }
// 
// }


// Path: src/main/java/org/apache/commons/fileupload2/util/Streams.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.fileupload2.InvalidFileNameException;

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        copy(inputStream, baos, true);
        return baos.toString(encoding);
    }

    /**
     * Checks, whether the given file name is valid in the sense,
     * that it doesn't contain any NUL characters. If the file name
     * is valid, it will be returned without any modifications. Otherwise,
     * an {@link InvalidFileNameException} is raised.
     *
     * @param fileName The file name to check
     * @return Unmodified file name, if valid.
     * @throws InvalidFileNameException The file name was found to be invalid.
     */
    public static String checkFileName(final String fileName) {
        if (fileName != null  &&  fileName.indexOf('\u0000') != -1) {
            // pFileName.replace("\u0000", "\\0")
            final StringBuilder sb = new StringBuilder();
            for (int i = 0;  i < fileName.length();  i++) {
                final char c = fileName.charAt(i);
                switch (c) {
                    case 0:
                        sb.append("\\0");
                        break;
                    default:
                        sb.append(c);
                        break;
                }
            }
            throw new InvalidFileNameException(fileName,