Tag: check

Java

Check if file or directory exists in Java

Check if file exists: File f = new File("/path/to/filename"); if(f.exists()){ .. }File f = new File("/path/to/filename"); if(f.exists()){ .. } Check if directory exists: File f = new File("/path/to/folder/"); if(f.exists() && f.isDirectory()){ .. }File f = new File("/path/to/folder/"); if(f.exists() && f.isDirectory()){ .. }

Microsoft Windows Server 2003, Microsoft Windows Server 2008, Windows 7

Check Status of Windows Service

To check if a local or a remote Windows service is running or not, create a batch file, name it for ex. check_service.bat and paste the following code: @echo off sc \localhost query Apache2.2 > service_status.txt Find /i "RUNNING" service_status.txt >> service_status.txt IF %errorlevel% == 0 ( echo service is running ) ELSE ( echo …