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 으로 바 꿔 주세요.