package com.wgtgt.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
public class FileUtils {
	public static void join(String folder){
		try {
			File srcFolder=new File(folder);
			File[]files=srcFolder.listFiles();
			String fileName=getFileName(files);
			OutputStream fos=new FileOutputStream(folder+"/"+fileName);
			for (File file : files) {
				InputStream fis=new FileInputStream(file);
				int len=0;
				byte[]buffer=new byte[1024*8];
				while((len=fis.read(buffer))!=-1){
					fos.write(buffer, 0, len);
				}
				fis.close();
			}
			fos.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public static String getFileName(File[]files){
		ArrayList<String>list=new ArrayList<String>();
		for (File file : files) {
			list.add(file.getName());
		}
		String[]fileNames=new String[list.size()];
		fileNames=list.toArray(fileNames);
		return join(fileNames);
	}
	public static String join(String[]strs){
		if(strs==null||strs.length==0){
			return "sum";
		}
		StringBuilder start=new StringBuilder();
		StringBuilder end=new StringBuilder();
		String name=null;
		if(strs.length>0){
			name=strs[0];
			char[]chs=name.toCharArray();
	Label1:		for (int i = 0; i < chs.length; i++) {
				for (int j = 0; j < strs.length-1; j++) {
					try {
						if(strs[j].charAt(i)!=strs[j+1].charAt(i)){
							break Label1;
						}
					} catch (StringIndexOutOfBoundsException e) {
						break Label1;
					}
				}
					start.append(chs[i]);
			}
	Label2:		for (int i = 1; i < chs.length; i++) {
				for (int j = 0; j < strs.length-1; j++) {
					try {
						if(strs[j].charAt(strs[j].length()-i)!=strs[j+1].charAt(strs[j+1].length()-i)){
							break Label2;
						}
					} catch (StringIndexOutOfBoundsException e) {
						break Label2;
					}
				}
					end.insert(0,chs[chs.length-i]);
			}
		}
		String mid=name.substring(start.length(),name.length()-end.length());
		try {
			Integer.parseInt(mid);
			String startStr=start.toString();
			String endStr=end.toString();
			if(startStr.endsWith("[")&&endStr.startsWith("]")){
				return startStr.substring(0,startStr.length()-1)+endStr.substring(1);
			}
			if(startStr.endsWith("(")&&endStr.startsWith(")")){
				return startStr.substring(0,startStr.length()-1)+endStr.substring(1);
			}
			if(startStr.endsWith("{")&&endStr.startsWith("}")){
				return startStr.substring(0,startStr.length()-1)+endStr.substring(1);
			}
		} catch (NumberFormatException e) {
			
		}
		String startStr=start.toString();
		if(startStr.endsWith(".")){
			startStr=startStr.substring(0,startStr.length()-1);
		}
		String result=startStr+end.toString();
		return result;
	}
}
最近下载更多
                
                duxing     LV2
                2022年6月10日
            
            
        
                mylzdy     LV12
                2022年5月21日
            
            
        
                顾北城     LV12
                2022年5月8日
            
            
        
                zhenghongixin4065     LV9
                2021年1月25日
            
            
        
                3063686836     LV4
                2020年7月16日
            
            
        
                liuyilin9608     LV15
                2020年5月17日
            
            
        
                黄丹丹     LV2
                2020年1月17日
            
            
        
                wangyan110     LV2
                2019年11月7日
            
            
        
                初秋若寒     LV10
                2019年10月15日
            
            
        
                倪卟懂     LV18
                2019年7月23日
            
            
        
最近浏览更多
                
                    暂无贡献等级
            
        
                snowing_for     LV9
                2024年11月25日
            
            
        
                liu1221     LV1
                2024年4月20日
            
            
        
                Small CN     LV7
                2023年1月12日
            
            
        
                heqian     LV17
                2022年10月17日
            
            
        
                我们都是小怪兽     LV3
                2022年9月6日
            
            
        
                MoonSight     LV1
                2022年7月1日
            
            
        
                xuexizhuanyong23     LV16
                2022年6月29日
            
            
        
                lingqianjue     LV3
                2022年6月14日
            
            
        
                duxing     LV2
                2022年6月10日
            
            
        
                
                
                