经验分享之tips(3)
2017-04-27 15:16
134 查看
1、读取文件夹下的文件的个数
@Test
public void ddfd(){
File file = new File("E:\\PDF\\picture\\1acb15772e57497399dcbccf0de946dd\\pic"); //文件夹路径
File files[];
files = file.listFiles();
int num = files.length;
System.out.println("该文件夹下的文件个数为:"+num);
for(int i=0;i<files.length;i++)
{
System.out.println(files[i]);
}
}
2、JS 打开新窗口
a.超链接<a href="http://blog.csdn.net/helijie92902" title="我的博客">Welcome</a>
等效于js代码
window.location.href="http://blog.csdn.net/helijie92902"; //在同当前窗口中打开窗口
b.超链接<a href="http://blog.csdn.net/helijie92902" title="我的博客" target="_blank">Welcome</a>
等效于js代码
window.open("http://blog.csdn.net/helijie92902"); //在另外新建窗口中打开窗口
3、判空
工具类:
/**
* 判断字符串是否为空
* @param str 目标字符串
* @return
*/
public static boolean isEmpty(String str){
return str == null || str.isEmpty() || str.trim().length() == 0;
}
使用工具类:
//数据回显,根据传入的id是否为空来判断
if(!StringUtils.isEmpty(classifyPic.getId())){
classifyPic=classifyPicService.get(classifyPic.getId());
}
classifyPic.setParent(classifyPicService.get(classifyPic.getParent().getId()));
4、判断文件上传的类型是否时png和jpg
if(suffix.toLowerCase().equals("png")||suffix.toLowerCase().equals("jpg")){
System.out.println("文件格式正确,准备上传!");
}
5、获取url中"?"符后的字串
function GetRequest() {
var url = location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
@Test
public void ddfd(){
File file = new File("E:\\PDF\\picture\\1acb15772e57497399dcbccf0de946dd\\pic"); //文件夹路径
File files[];
files = file.listFiles();
int num = files.length;
System.out.println("该文件夹下的文件个数为:"+num);
for(int i=0;i<files.length;i++)
{
System.out.println(files[i]);
}
}
2、JS 打开新窗口
a.超链接<a href="http://blog.csdn.net/helijie92902" title="我的博客">Welcome</a>
等效于js代码
window.location.href="http://blog.csdn.net/helijie92902"; //在同当前窗口中打开窗口
b.超链接<a href="http://blog.csdn.net/helijie92902" title="我的博客" target="_blank">Welcome</a>
等效于js代码
window.open("http://blog.csdn.net/helijie92902"); //在另外新建窗口中打开窗口
3、判空
工具类:
/**
* 判断字符串是否为空
* @param str 目标字符串
* @return
*/
public static boolean isEmpty(String str){
return str == null || str.isEmpty() || str.trim().length() == 0;
}
使用工具类:
//数据回显,根据传入的id是否为空来判断
if(!StringUtils.isEmpty(classifyPic.getId())){
classifyPic=classifyPicService.get(classifyPic.getId());
}
classifyPic.setParent(classifyPicService.get(classifyPic.getParent().getId()));
4、判断文件上传的类型是否时png和jpg
if(suffix.toLowerCase().equals("png")||suffix.toLowerCase().equals("jpg")){
System.out.println("文件格式正确,准备上传!");
}
5、获取url中"?"符后的字串
function GetRequest() {
var url = location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
相关文章推荐
- 经验分享之tips(1)
- 经验分享之tips(2)
- 编程的一些经验分享Tips
- web架构设计经验分享
- 高通CAMIF和OV sensor调试经验分享(转)
- Cloudera Hue 使用经验分享,遇到的问题及解决方案
- matlab自学经验成果分享 将字符串中的特定字符替换成特定字符
- [转载]十年编程经验凝结 与新人们分享
- C#调用百度地图API经验分享(三)
- 一个软件测试人员的经验分享:做软件测试三,四年后的感想
- 网站推广,经验分享
- 关于Android在线支付Alipay(支付宝)开发的经验分享
- 使用Oracle SQL Developer从MySQL把数据移植到Oracle经验分享
- Oracle GoldenGate 实施经验分享
- EXT学习经验分享:深刻理解EXT与服务器端的交互
- 系统架构设计经验分享
- [转]国内外三个不同领域巨头分享的Redis实战经验及使用场景
- 经验分享:Xcode 创建.a和framework静态库
- 分享电商网站集成106短信接口和网银支付接口经验
- MySQL 性能优化的最佳20多条经验分享