|
@@ -420,9 +420,9 @@ public class EarmarkServiceImpl implements IEarmarkService {
|
|
// }
|
|
// }
|
|
//定义根路径
|
|
//定义根路径
|
|
//Linux
|
|
//Linux
|
|
-// String rootPath = request.getRealPath("/");
|
|
|
|
|
|
+ String rootPath = request.getRealPath("/");
|
|
//Windows
|
|
//Windows
|
|
- String rootPath = "D:\\";
|
|
|
|
|
|
+// String rootPath = "D:\\";
|
|
String basePath = rootPath + "temp_download";
|
|
String basePath = rootPath + "temp_download";
|
|
System.out.println("basePath>>"+basePath);
|
|
System.out.println("basePath>>"+basePath);
|
|
//创建文件
|
|
//创建文件
|
|
@@ -435,54 +435,56 @@ public class EarmarkServiceImpl implements IEarmarkService {
|
|
// String basePath = getResourceBasePath(request);
|
|
// String basePath = getResourceBasePath(request);
|
|
// System.out.println("basePath>>"+basePath);
|
|
// System.out.println("basePath>>"+basePath);
|
|
// String studentResourcePath = new File(basePath, "student/student.txt").getAbsolutePath();
|
|
// String studentResourcePath = new File(basePath, "student/student.txt").getAbsolutePath();
|
|
- File txtFile1 = new File(basePath, "eartag\\earmark_1.txt");
|
|
|
|
|
|
+// File txtFile1 = new File(basePath, "eartag\\earmark_1.txt");
|
|
|
|
+ File txtFile1 = new File(basePath, "eartag/earmark_1.txt");
|
|
System.out.println("txtFile1.exists()>>"+txtFile1.exists());
|
|
System.out.println("txtFile1.exists()>>"+txtFile1.exists());
|
|
// String studentResourcePath = txtFile1.getAbsolutePath();
|
|
// String studentResourcePath = txtFile1.getAbsolutePath();
|
|
// System.out.println("studentResourcePath = " + studentResourcePath);
|
|
// System.out.println("studentResourcePath = " + studentResourcePath);
|
|
// 保证目录一定存在
|
|
// 保证目录一定存在
|
|
// ensureDirectory(studentResourcePath);
|
|
// ensureDirectory(studentResourcePath);
|
|
|
|
|
|
-// BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(studentResourcePath)));
|
|
|
|
-//// for (Student student : students) {
|
|
|
|
-//// StringBuffer buffer = new StringBuffer();
|
|
|
|
-//// buffer.append(student.getName());
|
|
|
|
-//// buffer.append("\t");
|
|
|
|
-//// buffer.append(student.getAge());
|
|
|
|
-//// buffer.append("\t");
|
|
|
|
-//// buffer.append(student.getSex());
|
|
|
|
-//// buffer.append("\r\n");
|
|
|
|
-//// writer.write(buffer.toString());
|
|
|
|
-//// }
|
|
|
|
-// String text = "测试内容";
|
|
|
|
-// writer.write(text);
|
|
|
|
-// writer.flush();
|
|
|
|
-// writer.close();
|
|
|
|
- File txtFile2 = new File(basePath, "eartag/earmark_2.txt");
|
|
|
|
- System.out.println("txtFile2.exists()>>"+txtFile2.exists());
|
|
|
|
- File txtFile3 = new File(basePath, "eartag/earmark_3.txt");
|
|
|
|
- System.out.println("txtFile3.exists()>>"+txtFile3.exists());
|
|
|
|
|
|
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(txtFile1)));
|
|
|
|
+// for (Student student : students) {
|
|
|
|
+// StringBuffer buffer = new StringBuffer();
|
|
|
|
+// buffer.append(student.getName());
|
|
|
|
+// buffer.append("\t");
|
|
|
|
+// buffer.append(student.getAge());
|
|
|
|
+// buffer.append("\t");
|
|
|
|
+// buffer.append(student.getSex());
|
|
|
|
+// buffer.append("\r\n");
|
|
|
|
+// writer.write(buffer.toString());
|
|
|
|
+// }
|
|
|
|
+ String text = "测试内容";
|
|
|
|
+ writer.write(text);
|
|
|
|
+ writer.flush();
|
|
|
|
+ writer.close();
|
|
|
|
+// File txtFile2 = new File(basePath, "eartag/earmark_2.txt");
|
|
|
|
+// System.out.println("txtFile2.exists()>>"+txtFile2.exists());
|
|
|
|
+// File txtFile3 = new File(basePath, "eartag/earmark_3.txt");
|
|
|
|
+// System.out.println("txtFile3.exists()>>"+txtFile3.exists());
|
|
List<File> fileList = new ArrayList();
|
|
List<File> fileList = new ArrayList();
|
|
fileList.add(txtFile1);
|
|
fileList.add(txtFile1);
|
|
- fileList.add(txtFile2);
|
|
|
|
- fileList.add(txtFile3);
|
|
|
|
|
|
+// fileList.add(txtFile2);
|
|
|
|
+// fileList.add(txtFile3);
|
|
|
|
|
|
// String fileName = "耳标数据下载" + "_" + dateUtil.formatLongTimeForTime(new Date().getTime());
|
|
// String fileName = "耳标数据下载" + "_" + dateUtil.formatLongTimeForTime(new Date().getTime());
|
|
String fileName = "耳标数据下载";
|
|
String fileName = "耳标数据下载";
|
|
String zipFileName = fileName + ".zip";
|
|
String zipFileName = fileName + ".zip";
|
|
System.out.println("zipFileName>>"+zipFileName);
|
|
System.out.println("zipFileName>>"+zipFileName);
|
|
|
|
|
|
- File filex = new File(basePath + "\\newFile.txt");
|
|
|
|
- System.out.println("###### filex.exists>>"+filex.exists());
|
|
|
|
- String resourcePath = txtFile1.getAbsolutePath();
|
|
|
|
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(resourcePath)));
|
|
|
|
- String text = "测试内容";
|
|
|
|
- writer.write(text);
|
|
|
|
- writer.flush();
|
|
|
|
- writer.close();
|
|
|
|
|
|
+// File filex = new File(basePath + "\\newFile.txt");
|
|
|
|
+// System.out.println("###### filex.exists>>"+filex.exists());
|
|
|
|
+// String resourcePath = txtFile1.getAbsolutePath();
|
|
|
|
+// BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(resourcePath)));
|
|
|
|
+// String text = "测试内容";
|
|
|
|
+// writer.write(text);
|
|
|
|
+// writer.flush();
|
|
|
|
+// writer.close();
|
|
|
|
|
|
// 打成压缩包
|
|
// 打成压缩包
|
|
// File zipFile = null;
|
|
// File zipFile = null;
|
|
- String zipPath = basePath + "\\eartag\\" + zipFileName;
|
|
|
|
|
|
+// String zipPath = basePath + "\\eartag\\" + zipFileName;
|
|
|
|
+ String zipPath = basePath + "/eartag/" + zipFileName;
|
|
System.out.println("zipPath>>"+zipPath);
|
|
System.out.println("zipPath>>"+zipPath);
|
|
File zipFile = new File(zipPath);
|
|
File zipFile = new File(zipPath);
|
|
System.out.println("zipFileexists.exists>>"+zipFile.exists());
|
|
System.out.println("zipFileexists.exists>>"+zipFile.exists());
|