合并两个表合并两个表合并两个表
struts2 多文件上传
public class UploadFileMutilAction extends ActionSupport
{
private File[] file;
private String[] fileFileName;
private String[] fileContentType;
private String path;
@Override
public String execute() throws Exception
{
String realPath = ServletActionContext.getServletContext().getRealPath(
path);
int poolSize = file.length;
ExecutorService es = Executors.newFixedThreadPool(poolSize);
for (int j = 0; j < poolSize; j++)
{
Runnable r = new UploadFileMutilThread(file[j], fileFileName[j],
realPath);
es.execute(r);
}
es.shutdown();
return SUCCESS;
}
public File[] getFile()
{
return file;
}
public void setFile(File[] file)
{
this.file = file;
}
public String[] getFileFileName()
{
return fileFileName;
}
public void setFileFileName(String[] fileFileName)
{
this.fileFileName = fileFileName;
}
public String[] getFileContentType()
{
return fileContentType;
}
public void setFileContentType(String[] fileContentType)
{
this.fileContentType = fileContentType;
}
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path = path;
}
}
public class UploadFileMutilThread implements Runnable
{
private File file;
private String FileName;
private String saveDir;
public UploadFileMutilThread(File files, String fileNames, String saveDir)
{
this.file = files;
FileName = fileNames;
this.saveDir = saveDir;
}
@Override
public void run()
{
File f = new File(saveDir);
if (!f.exists())
{
f.mkdirs();
}
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try
{
bis = new BufferedInputStream(new FileInputStream(file));
bos = new BufferedOutputStream(new FileOutputStream(new File(f,
FileName)));
byte[] b = new byte[2024];
int i = -1;
while ((i = bis.read(b)) != -1)
{
bos.write(b);
}
bis.close();
bos.close();
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
} finally
{
try
{
bis.close();
bos.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
}
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView listview = (ListView)this.findViewById(R.id.listview); String[] strs = new String[]{"2","0","1","dfdf","Uifd","太阳","oppopo","dfjdkfjd","ADFDFDFI","今天"}; List<String> aList = Arrays.asList(strs); StrCompare strCompare = new StrCompare(); Collections.sort(aList, strCompare); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strs); listview.setAdapter(adapter); } public class StrCompare implements Comparator<String>{ public int compare(String object1, String object2) { //默认升序排列 return object1.compareTo(object2); } }