You can make sure that your filenames are padded with zeros like this:
public String pad(String fileName, int len) {
if (fileName.length() >= len) {
return fileName;
}
String padded = "0000000" + fileName; // Change the number of zeros to your needs
return padded.substring(padded.length() - len);
}
Then you just have to prepend "ABC_" to the padded value:
String newName = "ABC_" + pad(oldNmame, 6); // produce 6 characters per String
produces results like:
10.pdf gets ABC_10.pdf
1.pdf gets ABC_01.pdf
a.pdf gets ABC_0a.pdf
100.pdf gets ABC_100.pdf
a.a gets ABC_000a.a