java-7

Recursively list files in Java

扶醉桌前 提交于 2019-11-25 21:59:45
问题 How do I recursively list all files under a directory in Java? Does the framework provide any utility? I saw a lot of hacky implementations. But none from the framework or nio 回答1: Java 8 provides a nice stream to process all files in a tree. Files.walk(Paths.get(path)) .filter(Files::isRegularFile) .forEach(System.out::println); This provides a natural way to traverse files. Since it's a stream you can do all nice stream operations on the result such as limit, grouping, mapping, exit early

Exception in thread “main” java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0) [duplicate]

让人想犯罪 __ 提交于 2019-11-25 21:36:09
Possible Duplicate: unsupported major .minor version 51.0 I installed JDK7, a simple hello word program gets compile but when I run this I got following exception. Exception in thread "main" java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source)

Java 7 (JDK 7) garbage collection and documentation on G1

梦想的初衷 提交于 2019-11-25 20:44:34
Java 7 has been out for a while now, but I cannot find any good resources on the configuration of the garbage collectors , specifically the new G1 collector . My questions: Is G1 the default collector in Java 7 and if not how do I activate G1? What optional settings does g1 have in Java7? Were there any changes made to other collectors like cms or the parallel collector in Java 7? Where can I find good documentation on garbage collection in Java 7? The G1 garbage collector is not the default in my installation of Java, version 1.7.0_01. You can see for yourself by using with some extra command