java 中如何将InputStream对象转换为OutputStream对象
方法签名:
public static OutputStream read(InputStream inStream)
------解决方案--------------------
http://www.cnblogs.com/vigarbuaa/archive/2013/01/13/2858859.html
------解决方案--------------------
InputStream in = new FileInputStream(new File("D:\\1.jpg"));
FileOutputStream fileOut = new FileOutputStream(new File(
"D:\\2.jpg"));
byte[] buf = new byte[1024 * 8];
while (true) {
int read = 0;
if (in != null) {
read = in.read(buf);
}
System.out.println(read);
if (read == -1) {
break;
}
fileOut.write(buf, 0, read);
}
fileOut.flush();
------解决方案--------------------
//获取当前类路径
String file = ClassLoader.getSystemClassLoader().getResource("").getFile();
------解决方案--------------------
System.out.println(Test1.class.getClassLoader().getResource("com/example/xml"));