Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 JAVA


  3 ways to remove duplicates in List

Frequently, we may have an ArrayList which stores many values, and we need to process the ArrayList and get what are the distinct values in the list, or we may want to count occurrence of each value in the ArrayList. We can remove the duplicates in a few ways. Here we propose 3 methods :    public static void main(String[] args){        //SuperClass sub=new SubClass();                String[] ar = { "dd", "c", "dd", "ff", "b", "e", "e" };        ArrayList list ...

8,972 0       JAVA CLEAR LIST DUPLICATE


  30 minutes to fix Java vulnerability

On September 25, Adam Gowdiak from the Polish security consulting firm Security Explorations submitted a Java security vulnerability to Oracle and provided a proof-of-concept. The vulnerability exists in Java 5 6,7, once the user accesses hosted malware site, an attacker can remotely control the infected machine.Gowdiak later got in touch again with Oracle and got the response that the fix has reached the final stage. He can expect the patch in four months later. He eventually unbearable Oracle's tedious development, testing processes, We should know that Oracle has to create 30 more patches f...

8,674 0       JAVA FIX VULNERABILITY


  IDEs for Java programmers

IDEs are great helpers to programmers. They can help programmers write less error-prone programs with less time. They have become an inevitable part of many programmers. As a Java developer, you may be familiar with Eclipse already. But do you know other IDEs for Java programmers?We will give an overview of different IDEs for Java programmers. These IDEs are Eclipse, Intellij IDEA, NetBean and BlueJ.EclipseEclipse is the most widely used IDE for Java programmers. It's an open source IDE which is originally developed by IBM. Now it can not only be used to write Java programs, but also C++, C, J...

8,638 4       ECLIPSE JAVA IDE BLUEJ NETBEANS


  Using MemoryMappedBuffer to handle large file in Java

When handling large files, it will largely affect the process speed while using traditional FileInputStream, FileOutputStream or RandomAccessFile since they trigger lots of read and write operations. In Java NIO, a new way of handling large file is introduced which is to use MmeoryMappedBuffer to create memory mapped file.Memory-mapped I/O uses the filesystem to establish a virtual memory mapping from user space directly to the applicable filesystem pages. With a memory-mapped file, you can pretend that the entire file is in memory and that you can access it by simply treating it as a very lar...

8,552 0       JAVA IO NIO


  Java SynchronizedList and Iterator

While reading some material about concurrency, I come up with some writing about using SynchronizedList wrap about normal List to enable synchronization. But one interesting thing ishttp://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedList%28java.util.List%29 It says    It is imperative that the user manually synchronize on the returned list when iterating over it:    1   List list = Collections.synchronizedList(new ArrayList());    2       ...    3   synchronized...

8,371 0      


  Launch Java process programmatically in Java

In some cases while working on some automation testcase, developers would like to launch Java process programmatically so that the tests can be ran without manual intervention. Java provides such methods to achieve this.ProcessBuilder can be used to build a Java process which can be launched when everything is ready. Basically it can take a list of parameters which are similar to the command line options/arguments. For example, if you want to launch a Java process, you can do following.public final class JavaProcess { private String output = ""; private String javaHome = ""; public ...

8,308 0       JAVA COMMAND LINE PROCESSBUILDER


  Why accessing Java HashMap may cause infinite loop in concurrent environment

HashMap in Java is frequently used to handle key/value pairs. But it is not a good candidate to be used in concurrent environment where ConcurrentHashMap should be used instead. If used in concurrent environment, it may cause lots of unexpected behavior even including make the program getting into an infinite loop situation.To understand how this can happen, let's first discuss how HaspMap works internally. In this post we will use implementation of HashMap before Java 8 as example, Java 8 provides a different version of HashMap implementation which is more efficient but more complicated as we...

8,282 0       JAVA HASHMAP INFINITE LOOP


  Java API vs Framework

What is the difference between a Java Library and a framework? The two concepts are essentially important for a Java developer. The most important difference between a library and a framework is Inversion of Control. It means that when you call a library you are in control. But with a framework, the control is inverted: the framework calls you. (This is called the Hollywood Principle: Don’t call Us, We’ll call You.) This is pretty much the definition of a framework. Basically, all the control flow is already in the framework, and there’s just a bunch of predefined white sp...

8,271 0       JAVA FRAMEWORK DIFFERENCE API LIBRARY