yangys
2024-05-07 9b677ea5c6978788d135fc15da3d78c5a93789c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.qianwen.smartman.modules.dnc.util;
 
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
public class FileUtils {
    private static final Logger log = LoggerFactory.getLogger(FileUtils.class);
 
    public static boolean hasSpecial(@NotNull String fileName) {
        char[] chars = fileName.toCharArray();
        List<Integer> list = Arrays.asList(34, 42, 47, 58, 60, 62, 63, 92, 124);
        for (char c : chars) {
            if (list.contains(Integer.valueOf(c))) {
                return true;
            }
        }
        return false;
    }
 
    public static byte[] inputStream2byte(InputStream inputStream) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] bytes = new byte[100];
        while (true) {
            try {
                try {
                    int rc = inputStream.read(bytes, 0, 100);
                    if (rc <= 0) {
                        break;
                    }
                    byteArrayOutputStream.write(bytes, 0, rc);
                } catch (Throwable th) {
                    try {
                        byteArrayOutputStream.close();
                    } catch (IOException e) {
                        log.error(e.getMessage());
                    }
                    throw th;
                }
            } catch (IOException e2) {
                log.error(e2.getMessage());
                try {
                    byteArrayOutputStream.close();
                } catch (IOException e3) {
                    log.error(e3.getMessage());
                }
            }
        }
        bytes = byteArrayOutputStream.toByteArray();
        try {
            byteArrayOutputStream.close();
        } catch (IOException e4) {
            log.error(e4.getMessage());
        }
        return bytes;
    }
}