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

 JAVA


  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,290 0      


  Signature sign/verification demo in Java

Digital signature is commonly used in areas where data authentication and integrity are required. It is extremely important to have signature while transferring sensitive data from one peer to other peers through network since there might be malicious applications or man-in-the-middle attacks which may alter the data along the way.Java provides some APIs to generate and verify digital signature. One important class is Signature. When generating the signature, a private key needs to be passed to initSign()When verifying the signature, a public key needs to be passed to initVerify()Java use...

10,863 0       JAVA SECURITY SIGNATURE


  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,500 0       JAVA IO NIO


  Use Java ThreadLocal with caution

According to Oracle documentation, ThreadLocal is a class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own, independently initialized copy of the variable. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread. In short, ThreadLocal variables are variables belong to a thread, not a class or an instance of a class.One common use of ThreadLocal is when you want to access some non thread-safe objects in threads without using ...

22,909 0       JAVA MEMORY LEAK THREADLOCAL


  A HTTPS client and HTTPS server demo in Java

In this post, I will create a HTTPS server and HTTPS client demo which can establish HTTPS communication between a server and a client using Java. This should be very useful when we want to test our understanding about SSL communication. We will use both a detailed SSL client and a simple HttpsURLConnection as the HTTPS client.Before creating the actual HTTPS server and HTTPS client, we first need to generate the keystore and truststore to be used by the server and client. To generate the keystore, we can follow instructions at Different types of keystore in Java -- JKS. In this demo, we ...

69,272 5       JAVA SSL DEMO HTTPS


  How Java Application Developers Can Build Secure Internet Based Apps?

There are few compiled solution tested by experts to guide Java application development and maintenance team how they can start safe journey on Internet. Strong encryption, wise passwords, secure hardware are few of the tech tools that should be used by Java app development team to secure their Internet based apps. The Internet is most amazing yet most risky platform where nobody knows either they are doing safe transaction on Internet or there is some dog watching out for data packets that are exchanged by you over web. So we cannot be sure that we are safe every time we are using Intern...

5,010 0       JAVA APPLICATION DEVELOPMENT JAVA APPLICATION MAINTENANCE


  Set file permission in Java

Prior to Java 6,  there is no good solution at the Java level to provide file permission management. You need to implement your own native methods or call the Runtime.exec() to invoke the system routine such as chmod in LInux. Since Java 6, Java introduces a set of methods which can be used to set the file permission at Java level. These methods include:File.setReadable(boolean);File.setWritable(boolean);FIle.setExecutable(boolean);File.setReadable(boolean, boolean);File.setWritable(boolean, boolean);FIle.setExecutable(boolean, boolean);Here File.setReadable(boolean, true) is the same as ...

26,782 0       JAVA FILE PERMISSION POSIX LEARNJAVA


  A simple tutorial on writing Java native program

Java provides Java Native Interface(JNI) to enable developers to write programs which can utilize the underlying native libraries of the operating system. The benefits of writing native code are that they normally provide better performance compared to Java codes. Sometimes if you want to utilize some system specific functions you may also want to use JNI. One main drawback of writing native code is that your application may not be platform independent anymore. This is not what Java is designed for.Today we will show you a small tutorial on how to write a Java program calling native code....

5,351 0       SAMPLE JAVA NATIVE INTERFACE JNI NATIVE CODE