Repository navigation
Expand file tree
/
Copy pathInvoiceExtract.java
More file actions
90 lines (58 loc) · 1.9 KB
/
Copy pathInvoiceExtract.java
File metadata and controls
90 lines (58 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.Collections;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.logging.Logger;
import java.io.File;
import java.io.FilenameFilter;
public class InvoiceExtract {
static String userName = "";
static String srcPath = "\\\\vik-test\\transfers\\AXD\\inbound\\europe";
static String destPath = "\\\\vik-test\\transfers\\AXD\\inbound\\europe\\invoice\\";
static Logger log = Logger.getLogger("InvoiceExtract");
public static void main(String[] args) {
if (args != null && args.length > 0){
userName = args[0];
srcPath = "C:\\Documents and Settings\\" + userName + "\\test\\in\\";
destPath = "C:\\Documents and Settings\\" + userName + "\\test\\out\\";
}
log.info("SRC PATH = " + srcPath);
log.info("DEST PATH = " + destPath);
// Select all *.invoice files to process
File files[];
File path = new File(srcPath);
InvoiceFilter filter = new InvoiceFilter();
files = path.listFiles(filter);
if (files == null || files.length < 1){
log.info("No files to send");
return;
}
//for (int i = 0; i < files.length; i++) {
for (int i = 0; i < 1; i++) {
InvoiceFile newInvoice = new InvoiceFile(srcPath + "\\" + files[i].getName(),destPath);
newInvoice.processInvoices();
}
}
}
/**
* Select only in* files.
* @param dir the directory in which the file was found.
* @param name the name of the file
*
* @return true if and only if the name should be included in the file list;
* false otherwise.
*/
class InvoiceFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
if (new File(dir, name).isDirectory())
return false;
name = name.toLowerCase();
return name.startsWith("in");
}
}