java


Java: Given a path to a file, create the folders to it

Assuming you have a full path to a file you want to create but the folder to it might exist or not, you can use the following code in your program to check if the folder exists and if it doesn’t, create it.

//The file we want to create;
final String logFileName = "./someFolder/anotherFolder/etc/myFile.txt";
//We find the last occurrence of the File.separator value, which will allow us to separate the path from the filename
final int lastIndex = logFileName.lastIndexOf(File.separator);
//The actual path we want to make sure it exists
final String dirPath = logFileName.substring(0, lastIndex > 0 ? lastIndex : logFileName.length());
//We try to use the folder by assigning it to a File object
final File theDir = new File(dirPath);
//Make the check that the folder exists
if (!theDir.exists()) {
    //If the folder does not exist, create it
    theDir.mkdirs();
}
//Continue with execution

On-screen clock/count down/counter (version 3, Java)

We ported the original watch from AutoHotKey to Java.

UPDATE: Click here [download id=”1262″] to download the application with a Windows launcher.

You can download the Java Jar version from this link : [download id=”1236″]

It started being used in the 106th IEEE Region 8 Committee Meeting that was held at the Fairmont Monte Carlo in Monaco on 19-20 of March 2016.

Key features

  • You can change the icon that appears in the task bar by placing an gif file with the name watch.gif in the config directory of the executable
  • You can drag the watch to a more convenient place with the mouse
  • You can move the watch using the arrow keys. Using the shift key it makes the movement more precise. Using the control key it makes the movement faster.
  • Double clicking on the watch it will hide it
  • Double clicking on the tray menu icon of the watch it will toggle it’s visibility
  • From the menu on the task bar you can “Set it on top”, allow mouse to click through the clock, hide/show the gui
  • You can set the color of the Font and the Color of the background using a color picker
  • You can set the transparency of the GUI
  • The tool has two modes, it can operate as a clock that shows time in 24 hour mode or AM/PM and can operate as a count down tool (timer)
  • The timer mode allows you to pause (and continue), reset and stop the time, reset and continue the time (using lap) or zero the clock

Good willed feedback is always welcome