Follow-up to How do I decode a base64 encoded URL from a test email using Katalon

Hi @kazurayam,
I have now have a folder where I need to select the LAST record in the list, the 3rd one in this example:

  1. 11bfe1ce-d122-41dc-8016-f9bd5de24ee1.eml
  2. 11bfe1ce-d122-41dc-8016-f9bd5de24ee2.eml
  3. 11bfe1ce-d122-41dc-8016-f9bd5de24ee3.eml

How can I change .sorted(Comparator.reverseOrder()) to pick the LAST record in the list?

 * @author kazurayam

import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kazurayam.study20221030.PathComparableByFileLastModified
import com.kms.katalon.core.util.KeywordUtil as KeywordUtil
import com.kms.katalon.core.configuration.RunConfiguration
import internal.GlobalVariable as GlobalVariable

dataDir = Paths.get('//s-test-bsl1//MailerPickupDirectory')
List<PathComparableByFileLastModified> emlFiles =
		.filter({ p -> p.toString().endsWith(".eml") })
		// wrap the Path object by a adapter class
		// to sort the Path objects by the Email Date in the file content
		.map({ p -> new PathComparableByFileLastModified(p) })
		// in the descending order of the Date value

emlFiles.eachWithIndex  { p, index ->
	println((index + 1) + "\t" + p.getTimestampFormatted() + "\t" + dataDir.relativize(p.get()))
//Opens the 1st eml file and reads contents
String contentOfFirstFile = emlFiles.get(0).get().toFile().text

For those who don’t know the previous discussion, I will note, @Dave_Evers looked at a previous post in this forum:

I tried your code, but it didn’t even compile with several compilation errors. I couln’t reproduce your problem.

My GitHub repository Dave_Evers_wants_to_sort_files_by_content/Keywords/my at master · kazurayam/Dave_Evers_wants_to_sort_files_by_content · GitHub no longer contains the PathComparableByFilesLastModified class which you are trying to make use of. I don’t remember if I have ever created it, or if yes, why the current repository misses it now . In short, I forgot this issue.

I am no longer interested in this issue. Please find the answer yourself.

1 Like

Hello @kazurayam,

As always thank you for your feedback and taking your valuable time to look into my issue. I was able to solve my issue using a different method. If you are able, please delete my original post. Or I can delete the post if you are good with that.

Best regards,

Let’s leave it as is

Thank you @kazurayam for all the solutions provided. I will mark the topic closed for you both. Thanks guys!