I am cheking for the exixtance of a file only for the first time i enter into the process. If the file exists then i renamed it and deleted the file. then i create a new file in that name. But in the following process an error is arising that the file not exists. Here is the code
File xlDir=new File("EXCEL");
if (!(xlDir.exists() && xlDir.isDirectory() ) ) {
xlDir.mkdir();
}
File xlFile1=new File("EXCEL\\"+justName.substring(0,justName.toLowerCase().lastIndexOf("."))+".xls");
if (!xlFlag && xlFile1.exists() ) {
System.out.println("File already exists");
File xlFileOld=new File("EXCEL\\old"+processID+"_"+justName.substring(0,justName.toLowerCase().lastIndexOf("."))+".xls");
if (xlFile1.renameTo(xlFileOld)) System.out.println("renamed");
if (xlFile1.delete()) System.out.println("deleted");
xlFlag=true;
}
if (!(xlFile1.exists() && xlFile1.isFile() )) {
if (xlFile1.createNewFile()) System.out.println("created new File");
}
File xlFile=new File("EXCEL\\"+justName.substring(0,justName.toLowerCase().lastIndexOf("."))+".xls");
if (xlFile.exists()) System.out.println("file Exists");
jxl.Workbook workbook;
jxl.write.WritableWorkbook workbook_W;
jxl.write.WritableSheet sheet;
workbook=jxl.Workbook.getWorkbook(xlFile);//HTML2TXT.java:1388--where error is arising
And here is the output
File already exists
renamed
created new File
file Exists
jxl.read.biff.BiffException: The input file was not found
at jxl.read.biff.File.<init>(File.java:124)
at jxl.Workbook.getWorkbook(Workbook.java:221)
at jxl.Workbook.getWorkbook(Workbook.java:198)
at HTML2TXT.writeTableInExcel(HTML2TXT.java:1388)
at HTML2TXT.writefinal(HTML2TXT.java:1100)
at HTML2TXT.FillTokens(HTML2TXT.java:1852)
at HTML2TXT.createtable(HTML2TXT.java:790)
at HTML2TXT.ReadHTML(HTML2TXT.java:171)
at FileWatcher.run(FileWatcher.java:53)
at java.lang.Thread.run(Unknown Source)
Any Ideas???