The same logic can be translated into Java. Just Google around to see how to open a directory and iterate through its files in Java. The code and comments should be self-explanatory.
def loadImagesFrom(folder):
for filename in os.listdir(folder): #iterate through the files inside the folder
print 'FileName', filename
# At this point, filename is just a string consisting of the file's given title.
# Simply passing that into OpenCV, will not work because that filename does not exist in the
# current directory. The file is located in folder/filename. In order to get the exact path,
# we use os.path.join. The final result will look something like this: /Images/car.png
# Thereafter we simply feed the path to OpenCV's imread'
image = cv2.imread(os.path.join(folder, filename))
# check to see if the image is not empty first.
# You can do this as well by checking if image.shape.isEmpty() or something along these lines
if image is not None:
# Do stuff with your image
else:
# Image is empty
EDIT 1
Iterate through folder in Java