Retrieve multiple columns from a csv file to generate a new file

I have a standard format csv file:

ID,Name,Gender,Age,Enabled

1,Kevin,M,1,true

2,James,M,2,true

3,Jane,F,3,true

4,Jenny,F,4,true

I need to use Java to do this: Take column names as the parameter to retrieve multiple columns and save them as a new file. For example, when the parameter is "ID,Name,Gender", the expected new file is as follows:

ID,Name,Gender

1,Kevin,M

2,James,M

3,Jane,F

4,Jenny,F

Write the following SPL code:

=T(\"d:\\result.csv\":T(\"d:\\data.csv\",${arg_cols}))

T()function parses a file or writes data of a file to a new one, where we can specify column names; ${} treats a string as an expression to execute.

Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.
Source:
https://stackoverflow.com/questions/69819686/how-to-extract-csv-columns-with-the-specific-header-names-and-output-to-a-new-fi