
isDirectory() // 该方法是用来测试此抽象路径名表示的文件是否是一个目录isFile() // 该方法是用来测试此抽象路径名表示的文件是否是一个标准文件
//判断是文件还是文件夹
public static void fileBox(){
File f = new File("f:"+Fileseparator+"1txt"); //f:\1txt
Systemoutprintln(Fileseparator);
if(fisDirectory())
Systemoutprintln("路径是目录");//如果是文件夹(Midir)
else
Systemoutprintln("路径不是目录"); //不是文件夹
}
html文件:
<div class="fileBox">
<div class="fileName"></div>
<button class="fileButton">选择文件</button>
<input type="file" class="file1">
</div>
<div class="fileBox">
<div class="fileName"></div>
<button class="fileButton">选择文件</button>
<input type="file" class="file2">
</div>
css文件:
fileBox{
position: relative;
display: inline-block;
}
fileButton{
display: inline-block;
width: 80px;
height: 34px;
line-height: 34px;
background: #FFA837;
border-radius: 0px 4px 4px 0px;
text-align: center;
color: #fff;
vertical-align: top;
}
file1,file2{
width: 80px;
height: 34px;
position: absolute;
top: 0px;
right: 0px;
opacity: 0;
filter:Alpha(opacity=0); /透明度兼容IE8/
vertical-align: top;
}
fileName{
display: inline-block;
width: 150px;
height: 34px;
line-height: 34px;
padding:0px 5px;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
border: 1px solid #eee;
vertical-align: top;
float: left;
}
js文件:
function upFile(fileX){
var path;
var fileName;
var file=fileX;
var fileFrame=fileXparent("fileBox")children("fileName");
path=fileval();
//path为获取的<input type="file">的文件名或文件路径
//火狐获取的是文件名,所以pos=-1,chrome和IE获取的是文件路径
if(path!=''){
var pos1 = pathlastIndexOf('/');
var pos2 = pathlastIndexOf('\\');
var pos = Mathmax(pos1, pos2)
if( pos<0 ){
fileName =path;
fileFrametext(fileName);
fileFrameattr("title",fileName);
}
else{
fileName=pathsubstring(pos+1);//截取从pos+1索引到末尾
fileFrametext(fileName);
fileFrameattr("title",fileName);
}
}
}
调用:
$("file1")change(function(){
upFile($(this));
});
$("file2")change(function(){
upFile($(this));
});
以后只要调用upFile()就可以了
兼容:IE8+,firefox,chrome
制作一个视频大概有三个步骤:一是采集视频,就是把摄像机里已经录好的视频通过采集导入电脑硬盘里,有的软件也叫捕捉;二是编辑,也叫制作,就是把采集到电脑里的视频调入编辑线,通过剪辑、加字幕、加背景音乐、加转场特技、加解说词等制作成**的过程;三是合成压缩,有的软件也叫分享或制作**,就是把在编辑线上制作完成的东西通过编辑软件自身的功能合成压缩成需要格式的视频文件或刻录成供电脑或播放机播放的视频光盘。
以上就是关于java判断文件是文件夹还是文件全部的内容,包括:java判断文件是文件夹还是文件、java判断文件是文件夹还是文件、前端怎么修改input file的默认样式等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)