-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadFile.java
More file actions
32 lines (32 loc) · 1.46 KB
/
ReadFile.java
File metadata and controls
32 lines (32 loc) · 1.46 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
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Scanner;
public class ReadFile {
public static void main(String[] args) throws IOException {
BufferedReader inputStream = null;
Scanner scanned_line = null;
String line;
String[] value;
value = new String[7];
int countv;
try {
inputStream = new BufferedReader(new FileReader("debito-populate-table.txt"));
while ((line = inputStream.readLine()) != null) {
countv=0;
System.out.println("<<");
//split fields separated by tab delimiters
scanned_line = new Scanner(line);
scanned_line.useDelimiter("\t");
while (scanned_line.hasNext()) {
System.out.println(value[countv++]=scanned_line.next());
} //while
if (scanned_line != null) { scanned_line.close(); }
System.out.println(">>");
System.out.println("insert into debito (numero_debito, valor_debito, motivo_debito, data_debito, numero_conta, nome_agencia, nome_cliente) " + "values (" +
value[0] +", "+ value[1] +", "+ value[2] +", '"+ value[3] +"', "+ value[4] +", '"+ value[5]
+"', '"+ value[6] + "');" );
} //while
} finally { if (inputStream != null) { inputStream.close(); } } //if & finally
} //main
}//class