由于项目需要,需要往共享盘中写入excel文件,利用java的io,输入输出流,搭建好共享盘,然后利用java进行写入共性盘任意格式的数据,以下是代码仅供参考:
String srcPath = "C:\\Users\\Administrator\\Desktop\\123.mp4";
File parentDir = new File("\\\\169.254.205.73\\测试");File targetPath = new File(parentDir, UUID.randomUUID().toString().replaceAll("-", "") + ".mp4");// .后边可以改任意格式
InputStream in = new FileInputStream(srcPath);
OutputStream out = new FileOutputStream(targetPath);
try {
byte[] bs = new byte[1024];
int len = -1;
while ((len = in.read(bs)) != -1) {
out.write(bs, 0, len);
}
} finally {
try {
out.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("上传成功!!");: