Java, fill each row having a null value in a csv file with values in the directly previous row

In the csv file below, Number column has some null values.

Number,PartType

1,A

2,B

,C

,D

5,E

,F

6,

,

,I

Task: Use Java to modify the file. The rule is like this: When a Number value is null, modify values of the current row as those of the directly previous row and save result as a new csv file.

Number,PartType

1,A

2,B

2,B

2,B

5,E

5,E

6,

6,

6,

Write the following SPL statement:

=T(""result.csv"":T(""data.csv"").(~=if(Number,~,~[-1])))

T()function reads data from or writes data to a csv file. ~ is the current record, and ~[-1] represents the directly previous record.

Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.
Source:
https://stackoverflow.com/questions/73338375/get-previous-element-from-a-list-java