Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
How to exclude fille already inserted using java
Sharon Wong
Ranch Hand
Posts: 39
I like...
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi team,
how to exclude file already inserted using
java
? my folder will keep update new file, now how to only update the latest file?
public void File lastFileModified(String dir) { File f = null; File f1 = null; String path = ""; boolean bool = false; try { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); // create new files f = new File(dir); // create new file in the system f.createNewFile(); // create new file object from the absolute path f1 = f.getAbsoluteFile(); // returns true if the file exists bool = f1.exists(); // returns absolute pathname path = f1.getAbsolutePath(); BodyContentHandler handler = new BodyContentHandler(); Metadata metadata = new Metadata(); if(bool ){ FileInputStream inputstream = new FileInputStream(new File(path)); ParseContext pcontext = new ParseContext(); //parsing the document using PDF parser PDFParser pdfparser = new PDFParser(); pdfparser.parse(inputstream, handler, metadata,pcontext); /* IndexItem pdfIndex = index(sSrcFileNameWithFullPath); String fileContents = readContent( new File( sSrcFileNameWithFullPath ) );*/ newsContentObj.setContent(handler.toString()); out.println("contents test :" + newsContentObj.getContent()); } String Json = gson.toJson(newsContentObj); // out.println("String Builder :" +sContent.toString()); out.println("sNewsID :" + sNewsID); out.println("JSON :" + Json); sendIndexer(sNewsID, Json); } catch (Exception ex) { out.println("News Id :" + sNewsID + " -> Exception :" + ex); ex.printStackTrace(); } }
i have try to use it, but it still extract the file, although it is new file.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
xml to json using gson
Java to JSON Writer
how to grab value from arraylist
Read and Send JSON data in a java servlet
How to make it relative path?
More...