batch list data set

method one

package com.nantian.winUtliTest.BaiWan;

import java.util.ArrayList;
import java.util.List;

/ **
* Test data processing up to a million 10W
* @ClassName: the Test
* @Description: TODO
* @author: 92,649,498
* @date: 2019 Nian 12 12 afternoon 4:14:00
* Class EXPLAIN:
* /
public {Test class
public static void main (String [] args) {
List <String> a new new = the ArrayList (); // a list is only used for counting
List <String> a1 = new ArrayList (); // a a just used for counting list
List b = new ArrayList (); // data actually stored
a1.add ( "B");
for (int I = 0; I <100; I ++) {
System.out.println ( " A1 "+ a.size ());
a.add (I, a1.get (0) + I);
}





for (int I =. 1; I <a.size () +. 1; I ++) {
b.add (a.get (I -. 1));
IF (I% 10 == 0) {// each per treatment
System.out.println ( "per treatment 100000W" + i + "- Data Processing blacklist" + b);

b.clear();
}

IF (I a.size == ()) {
System.out.println (I + "-" + B);
// Last
b.clear ();
}

}
}





}

 Method Two

package com.nantian.winUtliTest.BaiWan;

import java.util.ArrayList;
import java.util.List;

/ **
* Batch processing one million data
* @ClassName: test2
* @Description: TODO
* @author: 92,649,498
* @date: 2019 Nian 12 14 afternoon 11:05:21
* Class EXPLAIN:
* /
public class test2 {
public static void main (String [] args) {
List <Object> = new new List the ArrayList <Object> ();
for (int I = 0; I <500; I ++) {
List.add (I);
}
test2. test1 (List);
}
public static void test1 (List <Object> dataList) {
int pointDataLimit = 100; // how much processing each time? Article
List <Object> = new new newList the ArrayList <Object> ();
for (int I = 0; I <dataList.size (); I ++) {
// batches processed
newList.add (dataList.get (i)) ;

if(pointDataLimit == newList.size()||i == dataList.size()-1){
printList(newList);
newList.clear();
System.out.println("*");
System.out.println("====");
}
}
}
public static void printList(List<Object> dataList){
for(Object str : dataList){
System.out.print(str + "--");
}
}
}

                      Method Three

package com.nantian.winUtliTest.BaiWan;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;

import com.nantian.common.ConnectionPool;
import com.nantian.service.getBlackListService;

public class test3 {

static void main public (String [] args) {
the HashMap <String, String> = new new returnMap is the HashMap <String, String> ();

List <String> Lines new new = the ArrayList <String> (); // increment source blacklist data
// December 13, 2019 revised blacklist name each treatment if less than 10W 10w deal directly
// only the total number of files is less than 100W will write caching December 9, 2019
the try {
Lines = FileUtils.readLines // write cache file;: ( "\\ WindowsETC ETC_Managent \\ \\ \\ ETCPMC blackListFile the UH-191214-06-11-D"), Charset.forName ( "GBK") new new (file)
} the catch ( E IOException) {
// the TODO Auto-Generated Block the catch
e.printStackTrace ();
} the finally {
// logger.info ( "[download services blacklist:] delete file");
// Boolean delDirUtil2 = winZipUtil.delDirUtil (blackListFilePath , blackListFilePath1,
// blackListFilePath2);
// filter to increase or delete
System.out.println ( "[blacklist download service:] start processing data altogether =" + (lines.size () - 1) + "=" lines.get + (0));
// If the delta blacklist data for each treatment than 10W 10W
int pointDataLimit = 100000; // how much each treatment? Article
List <String> = new new newList the ArrayList <String> ();
for (int I = 0; I <lines.size (); I ++) {
// batches processed
newList.add (lines.get (i)) ;
IF (pointDataLimit newList.size == () || I lines.size == () -. 1) {
for (String String: newList) {
IF (String.Contains ( "D")) {
String String = the replaceAll. the replaceAll ( "D", "");
rwFile (the replaceAll + "-");
of System.out.print (the replaceAll + "-");
}
IF (String.Contains ( "A")) {
String String = the replaceAll. replaceAll ( "A", "

System.out.print(replaceAll+"--");
}
}
newList.clear();
rwFile("*");
rwFile("====");
System.out.println("*");
System.out.println("====");
}
}



}

}


public static void rwFile(String string){
FileWriter fw = null;
try {
fw = new FileWriter("C:\\Users\\92649498\\Desktop\\1111.txt", true);//路径一定要用"\\"
fw.write(string);//这里向文件中输入结果123
fw.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fw != null) {
try {
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

public static void rwFile2(String string){
FileWriter fw = null;
try {
fw = new FileWriter("C:\\Users\\92649498\\Desktop\\2222.txt", true);//路径一定要用"\\"
fw.write(string);//这里向文件中输入结果123
fw.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fw != null) {
try {
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}

Guess you like

Origin www.cnblogs.com/wzy-525/p/12059512.html