8/31 学习记录
一、页面跳转的两种方式
windows.open(URL);//新窗口打开
windows.location.href(URL);//本窗口打开
二、永中在线浏览文件
三、从配置文件中取值
1、在使用类上加@component注解
2、并在使用值上加@value("${ location-path }")
四、文件读写
public String uploadCV(MultipartFile file) {
System.out.println(path);
//1、文件读写流
InputStream inputStream = null;
FileOutputStream outputStream =null;
String filePath = "";
try {
//2、定义写一次的长度
int index;
inputStream = file.getInputStream();
String filename = file.getOriginalFilename();
String date = new DateTime().toString("MM-dd-mm-ss");
filePath = path + "\\" + date + "_" + filename;
//3、写一次的内容
byte[] bytes = new byte[1024];
outputStream = new FileOutputStream(filePath);
//4、判断是否还有内容
while ((index = inputStream.read(bytes)) != -1){
outputStream.write(bytes,0,index);
outputStream.flush();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
//5、关闭IO流
try {
if (outputStream!=null)
outputStream.close();
if (inputStream!=null)
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return filePath;
}
五、获取时间以及时间工具类
String dateFormat = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
String result = sdf.format(new Date());
|_Calendar类的学习 ***