java - why file is not deleted inspite of using delete function? -
(int = 0; < listoftempfiles.length; i++) { (int j = 0; j < listoffaqfiles.length; j++) { if (listoftempfiles[i].isfile() && listoftempfiles[i].length() > 0) { if (listoftempfiles[i].getname().tolowercase().contains(".pdf")) { if (listoftempfiles[i].getname().substring(listoftempfiles[i].getname().lastindexof("#") + 1).equals(listoffaqfiles[j].getname())) { try { list<inputstream> list = new arraylist<inputstream>(); list.add(new fileinputstream(listoftempfiles[i])); list.add(new fileinputstream(listoffaqfiles[j])); system.out.println(listoftempfiles[i].getname() + "with faq: " + listoffaqfiles[j].getname()); int iend = listoftempfiles[i].getname().lastindexof("#"); if (iend != -1) { outputfilename = listoftempfiles[i].getname().substring(0, iend); } outputstream out = new fileoutputstream(new file(finalpdfparh + "/" + outputfilename + ".pdf")); domerge(list, out); boolean flag=listoftempfiles[i].delete(); system.out.println("flag----->"+flag); list.clear(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (documentexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } public static void domerge(list<inputstream> list, outputstream outputstream) throws documentexception, ioexception { document document = new document(); pdfwriter writer = pdfwriter.getinstance(document, outputstream); document.open(); pdfcontentbyte cb = writer.getdirectcontent(); (inputstream in : list) { pdfreader reader = new pdfreader(in); (int = 1; <= reader.getnumberofpages(); i++) { document.newpage(); //import page source pdf pdfimportedpage page = writer.getimportedpage(reader, i); //add page destination pdf cb.addtemplate(page, 0, 0); } } outputstream.flush(); document.close(); outputstream.close(); }
i want delete original file listoftempfiles after merges faq file.domerge methhod merges pdf added in list.i have used delete function not deleted?what can it? have used delete function.
Comments
Post a Comment