1 package net.sf.flatpack.examples.largedataset.fixedlengthdynamiccolumns;
2
3
4
5
6
7
8 import java.io.File;
9
10 import net.sf.flatpack.DataSet;
11 import net.sf.flatpack.brparse.BuffReaderFixedParser;
12 import net.sf.flatpack.brparse.BuffReaderParseFactory;
13
14 /**
15 * @author zepernick
16 *
17 * TODO To change the template for this generated type comment go to Window -
18 * Preferences - Java - Code Style - Code Templates
19 */
20 public class LargeFixedLengthWithPZMap {
21 public static void main(final String[] args) throws Exception {
22 final String mapping = getDefaultMapping();
23 final String data = getDefaultDataFile();
24 call(mapping, data);
25 }
26
27 public static String getDefaultDataFile() {
28 return "PEOPLE-FixedLength.txt";
29 }
30
31 public static String getDefaultMapping() {
32 return "PEOPLE-FixedLength.pzmap.xml";
33 }
34
35 public static void call(final String mapping, final String data) throws Exception {
36 String[] colNames = null;
37 BuffReaderFixedParser pzparse = null;
38 try {
39 pzparse = (BuffReaderFixedParser) BuffReaderParseFactory.getInstance().newFixedLengthParser(new File(mapping), new File(data));
40
41 final DataSet ds = pzparse.parse();
42 colNames = ds.getColumns();
43
44 while (ds.next()) {
45 for (int i = 0; i < colNames.length; i++) {
46 System.out.println("COLUMN NAME: " + colNames[i] + " VALUE: " + ds.getString(colNames[i]));
47 }
48
49 System.out.println("===========================================================================");
50 }
51
52 } finally {
53 pzparse.close();
54 }
55
56 }
57 }