| | |
| | | package org.fanli.dynamic;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStreamReader;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import java.util.TreeMap;
|
| | |
|
| | | import org.junit.Test;
|
| | |
|
| | | import com.yeshi.fanli.entity.dynamic.InviteMaterial;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.InviteMaterialService;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class Test_InviteMaterialService {
|
| | |
|
| | | |
| | | @Test
|
| | | public void insertMaterial() {
|
| | | try {
|
| | |
| | | String fliePath = "F:\\company_material\\invite\\name.txt";
|
| | | // File file = new File("F:\\company_material\\invite\\name.txt");//Text文件
|
| | | // BufferedReader buff = new BufferedReader(new FileReader(file));// 构造一个BufferedReader类来读取文件
|
| | | BufferedReader buff = new BufferedReader(new InputStreamReader(new FileInputStream(fliePath),"gbk"));
|
| | | |
| | | BufferedReader buff = new BufferedReader(new InputStreamReader(new FileInputStream(fliePath), "gbk"));
|
| | |
|
| | | while ((s = buff.readLine()) != null) {// 使用readLine方法,一次读一行
|
| | | if (!StringUtil.isNullOrEmpty(s)) {
|
| | | list.add(s.trim());
|
| | |
| | | buff.close();
|
| | |
|
| | | // 图片格式
|
| | | int startPic = 118;
|
| | | int endPic = 141;
|
| | | int startPic = 332;
|
| | | int endPic = 366;
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | String text = list.get(i);
|
| | | if (startPic > endPic) {
|
| | |
| | | }
|
| | | InviteMaterial record = new InviteMaterial();
|
| | | record.setText(text);
|
| | | record.setPicture("http://img.flqapp.com/resource/invite/everyday/"+ startPic +".jpg");
|
| | | record.setPicture("http://img.flqapp.com/resource/invite/everyday/" + startPic + ".jpg");
|
| | | record.setState(0);
|
| | | service.insert(record);
|
| | | startPic ++;
|
| | | |
| | | if (i == list.size()-1) {
|
| | | startPic++;
|
| | |
|
| | | if (i == list.size() - 1) {
|
| | | System.out.println("---------------------------------");
|
| | | System.out.println(text);
|
| | | System.out.println("---------------------------------");
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | // 图片重命名
|
| | | public static void main(String[] args) throws IOException {
|
| | | File[] file = new File("F:\\company_material\\pic").listFiles();
|
| | | int start = 500;
|
| | | for (int i = 0; i < file.length; i++) {
|
| | | // 得到图片
|
| | | File f = file[i];
|
| | | rename(f, start + "");
|
| | | start ++;
|
| | | }
|
| | | }
|
| | |
|
| | | private static void rename(File f, String name) throws IOException {
|
| | | FileInputStream fin = new FileInputStream(f);
|
| | | String s = new String("F:/company_material/imgs/" + name + ".jpg");
|
| | | FileOutputStream fou = new FileOutputStream(s);
|
| | | byte[] b = new byte[1024];
|
| | | int len;
|
| | | while ((len = fin.read(b)) != -1) {
|
| | | fou.write(b, 0, len);
|
| | | fou.flush();
|
| | | }
|
| | | fin.close();
|
| | | fou.close();
|
| | | }
|
| | | }
|