windows下tomcat安装版的安装及配置
文件放在:
Tomcat\webapps\ziyuanbao\文件
安装主目录\webapps\自己定义一个文件夹也可以\就是文件(图片)
http://localhost:8080/ziyuanbao/cji.png
协议
@Test
public void test3() throws IOException {
URL url = new URL("http://localhost:8080/ziyuanbao/cji.png");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream("Test930.png");
byte[] bytes = new byte[1024];
int len;
while ((len = inputStream.read(bytes)) != -1) {
fileOutputStream.write(bytes, 0, len);
}
fileOutputStream.close();
inputStream.close();
}