And yes, the code above finally solves the problem. I just noticed that now. Thanks everyone for your help

It is not feasible because what I have is as stated below:

FileOutputStream fop;
int counter = 1;
ResultSet result = statement.executeQuery("SELECT * FROM myTable WHERE columnID < 45");
while ({
    File file = new File("C:/result"+counter+".txt");
    fop = new FileOutputStream(file);
    String output = result.getString(1);
    byte[] byteValue = output.getBytes();           

How would I have the array for the results since they are going to be returned with a single select statement as the first option does not seem feasible

SELECT * FROM myTable WHERE columnId < 45; 

while ({ 
result of row1 goes to row1.txt; 
result of row2 goes to row2.txt; 
result of row3 goes to row3.txt; 
result of row4 goes to row4.txt;