📄 fileutil.java
字号:
/**
*文件功能:
*/
package com.common.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* @作者 徐建协
* @日期 2008-3-22
*/
public class FileUtil {
/*******************
* 获取文件的后缀名
* @param fileName
* @return
*/
public static String getExt(String fileName){
String[] array=fileName.split("[.]");
if(array.length>0){
return array[array.length-1];
}
return null;
}
/************************8
* 自动创建目录
* @param dir
* @return
*/
public static boolean creatDirs(String dir) {
boolean res = false;
File file = new File(dir);
try {
if (!file.exists()) {
file.mkdirs();
}
res = true;
} catch (Exception ex) {
}
return res;
}
public static void copyFile(File srcFile,String targetPath) throws Exception{
FileInputStream fileIn = new FileInputStream(srcFile);
FileOutputStream outStream =new FileOutputStream(targetPath);
byte[] buffer = new byte[(int) srcFile.length()];
int len = 0;
len = fileIn.read(buffer);
outStream.write(buffer);
outStream.close();
outStream.close();
}
public static byte[] getBytes(File f) throws Exception {
byte[] buffer = new byte[(int) f.length()];
int len = 0;
FileInputStream fileIn = new FileInputStream(f);
len = fileIn.read(buffer);
fileIn.close();
return buffer;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -