https,http,로 컬 URL

795 단어 IO 흐름
말 이 많 지 않 으 면 코드 를 달 아 라.
    public static InputStream byteByUrl(String urlOrPath) throws IOException {
        InputStream in = null;
        byte[] bytes;
        if (urlOrPath.toLowerCase().startsWith("https")) {
            bytes = HttpsUtils.doGet(urlOrPath);
        } else if (urlOrPath.toLowerCase().startsWith("http")) {
            URL url = new URL(urlOrPath);
            return url.openStream();
        } else {
            File file = new File(urlOrPath);
            if (!file.isFile() || !file.exists() || !file.canRead()) {
                return null;
            }
            return new FileInputStream(file);
        }
        return new ByteArrayInputStream(bytes);
    }

https,http,로 컬 URL 가 져 오기  그리고 InputStream 으로 바 꿔 주세요.

좋은 웹페이지 즐겨찾기