get first 5 characters of string java

Java
firstFourChars = input.substring(0, 4);
Source

Also in Java: