jollyplay
Programmer
- Dec 16, 2003
- 90
Hi,
In my struts application I'm inserting records to the database. I am getting the csv file from the user using html:file.
Using FileInputStream I'm reading the file. It is working fine in the localhost. But if we upload the classfile in the server "FileNotFoundException" is raised.
This is my Action class.
FileInputStream fin = new FileInputStream(filename); //filename - user selected file with path
StringTokenizer sToken;
BufferedReader myInput = new BufferedReader(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null)
{
sToken=new StringTokenizer(thisLine, ",");
appendSql="";
while(sToken.hasMoreTokens())
{
appendSql=appendSql+"'"+sToken.nextToken()+"',";
}
sql1="insert into "+table+" values("+appendSql+");";
//System.out.println(sql1.substring(0,sql1.lastIndexOf(",")));
writeSql=sql1.substring(0,sql1.lastIndexOf(","));
sql=writeSql.concat(");");
stmt.execute(sql);
}
Kindly provide me solution for this. Its very urgent.
Thanks in advance.
In my struts application I'm inserting records to the database. I am getting the csv file from the user using html:file.
Using FileInputStream I'm reading the file. It is working fine in the localhost. But if we upload the classfile in the server "FileNotFoundException" is raised.
This is my Action class.
FileInputStream fin = new FileInputStream(filename); //filename - user selected file with path
StringTokenizer sToken;
BufferedReader myInput = new BufferedReader(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null)
{
sToken=new StringTokenizer(thisLine, ",");
appendSql="";
while(sToken.hasMoreTokens())
{
appendSql=appendSql+"'"+sToken.nextToken()+"',";
}
sql1="insert into "+table+" values("+appendSql+");";
//System.out.println(sql1.substring(0,sql1.lastIndexOf(",")));
writeSql=sql1.substring(0,sql1.lastIndexOf(","));
sql=writeSql.concat(");");
stmt.execute(sql);
}
Kindly provide me solution for this. Its very urgent.
Thanks in advance.