Category : IO

Locking a file is quite simple in Java. The FileChannel (Java Doc) provides all methods we need to lock files. The tryLock() (Java Doc) method will try to obtain the lock on the file without waiting. If the lock is acquired an instance of FileLock (Java Doc) is returned, otherwise this method returns null.

Albert Attard
Author: 3 years ago

The Windows operating system (Homepage) provides useful information about video files playable by Windows Media Player (Homepage). This information includes the video length, frame width and height and other similar properties. Unfortunately there is no Java API which can easily retrieve such information. Instead we need to rely on third party native libraries such as MediaInfo (Homepage) and create wrappers around it. In this article we will see how to use the aforementioned third party native library to retrieve the video properties from a Java application.

Albert Attard
Author: 3 years ago

Cryptographic Hash algorithms (Wiki), such as SHA-1 (Wiki), are known for digesting inputs of any size into a fixed length, nondeterministic, output. Irrespective of the input size, the output is always of a fixed length, 160 bits (or 20 bytes) in case of SHA-1. Different hash algorithms produce different lengths. When processing large inputs, such as large files, it is convenient to work with streams, rather than loading all input to memory first.

Albert Attard
Author: 3 years ago