open multiple text file to input to mysql
Hello everyone,
I am trying to figure a way to open multiple text files to "write" to seperate tables in a mysql db. When I try to open another FileInputStream my ide, (NetBeans) doesn't like it and I can't say I don't blame it. I am unfamiliar with how to do this. I have checked over my texts and searched and cannot seem to find the right thing. Here is what I have;
Code :
FileInputStream fstream = new FileInputStream("roster");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
ArrayList list = new ArrayList();
while ((strLine = br.readLine()) != null) {
list.add(strLine);
}
Iterator itr;
for (itr = list.iterator(); itr.hasNext();) {
String str = itr.next().toString();
String delims = "[ : L ]+";
String[] splitSt = str.split(delims);
String id = "", firstName = "", lastName = "";
for (int i = 0; i < splitSt.length; i++) {
id = splitSt[0];
firstName = splitSt[1];
lastName = splitSt[2];
}
int k = stmt.executeUpdate("insert into roster_cs368(id, firstName,"
+ "lastName) values('"+ id +"', '"+ firstName +"',"
+ " '"+ lastName +"')");
fstream.close();
}
This portion does work. How can I go about using FileInputSteam more than once? Some examples would really help.
Thank You everyone.
Re: open multiple text file to input to mysql
What do you mean by "doesn't like it"? Are you getting compiler error messages? If so, this has nothing to do with the IDE and all to do with Java not liking things. You will want to show us any and all error messages and indicate the lines that are causing your errors.
Re: open multiple text file to input to mysql
Quote:
Originally Posted by
curmudgeon
What do you mean by "doesn't like it"? Are you getting compiler error messages? If so, this has nothing to do with the IDE and all to do with Java not liking things. You will want to show us any and all error messages and indicate the lines that are causing your errors.
Figured it out, thanks.