Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a new file in Tomcat Server

Status
Not open for further replies.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top