code: public void openNextFile() {
  		if( inputFilePath == null || inputMethod != InputMethod.IMAGE )
  			return;
  
  		String path;
  		try {
  			// need to remove annoying %20 from the path is there is whitespace
  			path = URLDecoder.decode(inputFilePath, "utf-8");
  		} catch (UnsupportedEncodingException e) {
  			e.printStackTrace();
  			return;
  		}
  		File current = new File(UtilIO.ensureURL(path).getFile());
  		File parent = current.getParentFile();
  		if( parent == null )
  			return;
  
  		File[] files = parent.listFiles();
  		if( files == null || files.length <= 1 )
  			return;
  		File closest = null;
  
  		for (int i = 0; i < files.length; i++) {
  			File f = files[i];
  			String name = f.getName().toLowerCase();
  			// filter out common non image/video files
  			if( name.endsWith(".txt") || name.endsWith(".yaml") || name.endsWith(".xml"))
  				continue;
  
  			if( current.compareTo(f) < 0 ) {
  				if( closest == null || closest.compareTo(f) > 0 ) {
  					closest = f;
  				}
  			}
  		}
  
  		if( closest != null && closest.isFile() ) {
  			openFile(closest);
  		} else {
  			if( closest != null ) {
  				System.err.println("Next file isn't a file. name="+closest.getName());
  			} else {
  				System.err.println("No valid closest file found.");
  			}
  		}
  	}
docs: Opens the next file in the directory by lexicographical order.