An elegant way to extract 'Date' attribute from a File [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 months ago.
Improve this question
So I have multiple files (on Windows 10 operating system and NTFS file system) with 'Date' attributes as here
'Date' attributes are available in Windows File Explorer in the 'Details' view after enabling them.
I'm looking for the easiest way to extract this attribute in Java (or Scala). I've read about solutions that can extract modification/creation time but neither of them mentioned a 'Date' attribute alone.

So apparently this 'Date' attribute has the same value as 'Last Saved Date' which is attribute specific to Microsoft Office or only (?) Excel files...
The method to extract this data from a file in Scala (if you use org.apache.poi.hssf library) can look something like this
def getLastSaveDateTime(file: File): Date = {
val fileInputStream = new FileInputStream(file)
try {
val workbook = new HSSFWorkbook(fileInputStream)
workbook.getSummaryInformation.getLastSaveDateTime
} finally fileInputStream.close()
}

Related

XML Document Parsing in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to parse an XML document in java for a web service I'm making, and save the contents of it.
I need to save the name of the tags, if the tag has attributes save the attributes, and then save the data within those tags. These three items will be inserted into a database table with the three columns tags, attributes, and data.
I'm using the following java libraries:
javax.xml.parsers.DocumentBuilder
javax.xml.parsers.DocumentBuilderFactory
org.w3c.dom.Document, org.w3c.dom.NodeList
org.xml.sax.InputSource.
Any help would be much appreciated.
DISCLAIMER: I don't want to plagiarize so I didn't include code but included links to other tutorials that are VERY helpful to this topic.
First, you should read w3c dom's java API because it tells you a lot of useful functions that are very related to your question.
Second, this website contains a useful tutorial that's easy to understand and it contains the necessary information for you to get the attributes of tags.
Third, this website gives you info on how to get tagName when you are looping through elements.
Fourth, you should always read related API, google, and then post a question if you are have no clue after a LONG period of time.
Lastly, you should post a difference question or research on database FIRST before asking that question here. This question should only be about XML Document Parsing in Java.
We are not supposed to help you do anything so the API is the best help for you (and google).
API: https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/package-summary.html

Concurrent Hashmap clears itself. [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have a xml reader which reads the title and the name of a person in java from a rss feed. I accomplish this by using document builder in java. When I read the element title and element name, I put them into a concurrent hashmap. This is fine, I can get the values from the map. However I want this information to be stored there for some time limit and not call the document builder until this time limit has passed. But the problem is when I do not call the document builder and refresh the webpage my hashmap values seem not to be stored. Code is in java and wicket.
Thoughts ?
It may be that every time you're refreshing the page a new hashmap is built and the old one is simply discarded. You should make sure your data stays persistent.

Java rename and sort based upon the filename [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is there an easy way to create a method that enables you to take the date of a file's creation and append it to the front of the file name? Example is a file named blah1.doc that was created on December 4, 2010 be rename to 2010124blah.doc.
If that is possible, is there a way to sort the files based upon creation date and copy them to different folders based upon filename?
Since some Linux systems do not support creation timestamps, this is not always doable.
Use Java nio if you are working on a system that does provide timestamps.
Path file = ...;
BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
// create new file object
newFile = new File(attr.creationTime() + ".doc");
// rename file
oldFile.renameTo(newFile);

dictionary component in Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am looking for an open source dictionary, The user in my application enter city name in Hebrew, and I want to translate it to English. I have another component that can use only English city names.
Where can I find such a component?
I guess that your main problem is not how to match Hebrew names to English ones (once you have a list of pairs), but actually how to obtain the data of matchings between Hebrew and English names. I'll also guess that you are aiming for cities in Israel if you are speaking about hebrew names. Therefore I'd try the statistics from the central bureau of statistics - they have a table with hebrew city names, and their english corressponding names. You can find it here: http://www.cbs.gov.il/ishuvim/ishuvim_print.htm
Did you try to use one of the Map implementations? For example HashMap or TreeMap? I'd even say more: just store all localized names in resource files (properties format) and use ResourceBundle to access them.
for example call your file towns.properties
tel-aviv = Tel Aviv
jerusalem = Jerusalem
The Hebrew version of your file is towns-iw.properties
tel-aviv = תל אביב
jerusalem = ירושלים
Now using ResourceBundle API create Map that contains direct associations between English and Hebrew names. Then just use it.

Java postal address parser [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Somewhat related to this question, but in the absence of any answer about QuickBooks specifically, does anyone know of an address parser for Java? Something that can take unstructured address information and parse out the address line 1, 2 and city state postal code and country?
I do know that the Google Maps web service is great at doing this. So, if you want to use that, you could save a lot of effort.
The real issue here is that you need a worldwide database of city/country/province names to effectively parse UNSTRUCTURED addresses.
Here is how I build a URL for use by the Google Maps API in C#:
string url = "http://maps.google.com/maps/geo?key=" + HttpUtility.UrlEncode(this.apiKey) + "&sensor=false&output=xml&oe=utf8&q=" + HttpUtility.UrlEncode(location);
The SourceForge JGeocoder has an address parser that you may find useful. See http://jgeocoder.sourceforge.net/parser.html.
Might want to read this Stack Overflow question:
"Parse usable Street Address, City, State, Zip from a string". No actual Java code to do the job (just some VB), but there is some discussion of the problem and more info on the alternative John Gietzen mentions, of using a web service to interpret it for you.
The Mural project has an address parser: https://mural.dev.java.net/. I haven't figured out how to exract it from the larger Mural engine, but it does work based on some very limited tests.
See www.address-parser.com, they offer a web service for parsing international addresses.

Categories

Resources