private static void writeCss(String cssAllPath,String cssAllName){
File file = new File(cssAllPath);
File cssFile = new File(cssAllPath,cssAllName);
File[] tempList = file.listFiles();
BufferedWriter bw = null;
try {
//检测该目录下是否存在此文件,若不存在,创建
if(!cssFile.exists()){
cssFile.createNewFile();
}
//追加写入
bw = new BufferedWriter(new FileWriter(cssFile));
for (int i = 0; i < tempList.length; i++) {
if(tempList[i].isFile()){
}
}
}
bw.close();
} catch (IOException e) {
e.printStackTrace();
} finally{
if(bw != null){
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
File file = new File(cssAllPath);
File cssFile = new File(cssAllPath,cssAllName);
File[] tempList = file.listFiles();
BufferedWriter bw = null;
try {
//检测该目录下是否存在此文件,若不存在,创建
if(!cssFile.exists()){
cssFile.createNewFile();
}
//追加写入
bw = new BufferedWriter(new FileWriter(cssFile));
for (int i = 0; i < tempList.length; i++) {
if(tempList[i].isFile()){
String cssName = tempList[i].getName();
//写入css文件,判断文件夹下文件是以.css结尾
if ( cssName.endsWith(".css") ) {
//组装css格式
String css = "@import '"+cssName+"';\r\n";
//开始写入文件
bw.write(css);}
}
}
bw.close();
} catch (IOException e) {
e.printStackTrace();
} finally{
if(bw != null){
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
//生成css文件路径
String cssAllPath = “D:\\”;
//css文件名
String cssAllName = "integration.css";
writeCss(cssAllPath,cssAllName);
}