Skip to content
Advertisement

Tag: java-7

java.nio.file.Path for a classpath resource

Is there an API to get a classpath resource (e.g. what I’d get from Class.getResource(String)) as a java.nio.file.Path? Ideally, I’d like to use the fancy new Path APIs with classpath resources. Answer This one works for me:

mac os java version from root is different

after installing jdk7u5 for mac os I got different java-versions for “normal” user and root. java -version gives me the 7. sudo java -version gives me the 6. I’ve looked up in the /System/Library/Frameworks/JavaVM.framework/Versions/ found that there are some links. After I resolved the links to the real Directory I tried it again with the whole path. /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java -version ->

How to access a sub-file/folder in Java 7 java.nio.file.Path?

Java 7 introduced java.nio.file.Path as a possible replacement for java.io.File. With File, when I access a file under a specific, I would do: What’s the way to do this with Path? I supposed this will work: But calling parent.toString() seems ugly. Is there a better way? Answer Use the resolve method on Path. There are two methods with this name.

java @SafeVarargs why do private methods need to be final

I have a private method in an inner class which is private I would like to use the SafeVarargs annotation. However, I am required to either have a static or final method. Why does a private method need to be final as well? Isn’t this redundant? Answer It is redundant, and you bring up an excellent point. I think the

Advertisement