jdk1.5

Template design pattern in JDK, could not find a method defining set of methods to be executed in order

北城以北 提交于 2019-11-28 01:29:34
I am reading about Template design pattern . As per my current understanding, Template design pattern can be used when we have an algorithm with defined set of processes(methods) to be done in order. Main players are 1. Abstract Template class providing a template method defining the processes (methods) and the order of execution. Usually this method is made final, so as its behavior is not modified. Few of the processes(methods) mentioned in the template method are provided with default implementation and others depending upon the concrete classes extending the Abstract template class types

TimeZone.setDefault changes in JDK6

时光总嘲笑我的痴心妄想 提交于 2019-11-27 22:05:27
I just noticed that JDK 6 has a different approach to setting a default TimeZone than JDK5. Previously the new default would be stored in a thread-local variable. With JDK6 (I just reviewed 1.6.0.18) the implementation has changed, so that if the user can write to the "user.timezone" property, or if there is no SecurityManager installed, the timezone changes VM-wide! Otherwise a thread-local change occurs. Am I wrong? This seems to be quite a drastic change, and I couldn't find anything on the web about it. Here is the JDK6 code: private static boolean hasPermission() { boolean hasPermission =

Template design pattern in JDK, could not find a method defining set of methods to be executed in order

一世执手 提交于 2019-11-27 19:13:11
问题 I am reading about Template design pattern . As per my current understanding, Template design pattern can be used when we have an algorithm with defined set of processes(methods) to be done in order. Main players are 1. Abstract Template class providing a template method defining the processes (methods) and the order of execution. Usually this method is made final, so as its behavior is not modified. Few of the processes(methods) mentioned in the template method are provided with default

Cross-platform way to open a file using Java 1.5

最后都变了- 提交于 2019-11-27 17:52:48
问题 I'm using Java 1.5 and I'd like to launch the associated application to open the file. I know that Java 1.6 introduced the Desktop API, but I need a solution for Java 1.5 . So far I found a way to do it in Windows: Runtime.getRuntime().exec(new String[]{ "rundll32", "url.dll,FileProtocolHandler", fileName }); Is there a cross-platform way to do it? Or at least a similar solution for Linux ? 回答1: +1 for this answer Additionally I would suggest the following implementation using polymorphism:

How to redirect verbose garbage collection output to a file?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 10:50:38
How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows. From the output of java -X : -Xloggc:<file> log GC status to a file with time stamps Documented here : -Xloggc: filename Sets the file to which verbose GC events information should be redirected for logging. The information written to this file is similar to the output of -verbose:gc with the time elapsed since the first GC event preceding each logged event. The -Xloggc option overrides -verbose:gc if both are given with the same java command. Example: -Xloggc

TimeZone.setDefault changes in JDK6

纵饮孤独 提交于 2019-11-27 04:33:21
问题 I just noticed that JDK 6 has a different approach to setting a default TimeZone than JDK5. Previously the new default would be stored in a thread-local variable. With JDK6 (I just reviewed 1.6.0.18) the implementation has changed, so that if the user can write to the "user.timezone" property, or if there is no SecurityManager installed, the timezone changes VM-wide! Otherwise a thread-local change occurs. Am I wrong? This seems to be quite a drastic change, and I couldn't find anything on

How to redirect verbose garbage collection output to a file?

拥有回忆 提交于 2019-11-26 17:58:53
问题 How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows. 回答1: From the output of java -X : -Xloggc:<file> log GC status to a file with time stamps Documented here: -Xloggc: filename Sets the file to which verbose GC events information should be redirected for logging. The information written to this file is similar to the output of -verbose:gc with the time elapsed since the first GC event preceding each logged

How do I join two lists in Java?

不想你离开。 提交于 2019-11-26 00:39:33
问题 Conditions: do not modifiy the original lists; JDK only, no external libraries. Bonus points for a one-liner or a JDK 1.3 version. Is there a simpler way than: List<String> newList = new ArrayList<String>(); newList.addAll(listOne); newList.addAll(listTwo); 回答1: Off the top of my head, I can shorten it by one line: List<String> newList = new ArrayList<String>(listOne); newList.addAll(listTwo); 回答2: In Java 8: List<String> newList = Stream.concat(listOne.stream(), listTwo.stream()) .collect