Hi,
Im using <html:file> tag to upload one CSV file and i want to read that in Action Class.
Im trying to read file using FormFile:
FormFile myFile = myForm.getTheFile();
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
byte[] fileData = myFile.getFileData();
String thisLine; //string variable which take each record at a time
int count=0; //to count no. of records
FileInputStream fis = new FileInputStream(fileName);
DataInputStream myInput = new DataInputStream(fis);
while ((thisLine = myInput.readLine()) != null)
{ //beginning of outer while loop
StringTokenizer st =new StringTokenizer(thisLine,",");
while(st.hasMoreElements()){
String field = st.nextToken();
System.out.print(field+", ");
}
System.out.println();
} //ending of outer while loop
when i run
JSP in browser i get an error like this:
java.io.FileNotFoundException: BKHN-290709-050809.csv (The system cannot find the file specified)
I understood that, may be FileInputStream is not getting absolute path of that file. so that is giving that error. bcuz when i hardcode filepath it is working fine.
If that is correct, can anyone tell me how to get absolute path and try to solve this? i need this urgently
thanks
alot in advance