package de.sopa.helper;

/**
 * @author David Schilling - davejs92@gmail.com
 * @author Raphael Schilling
 */

import android.content.Context;

import de.sopa.manager.ResourcesManager;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import java.util.ArrayList;
import java.util.List;


public class FileHandler {

    private final Context context;

    public FileHandler(Context context) {

        this.context = context;
    }

    public void writeToFile(String filename, String[] strings) throws IOException {

        FileOutputStream fileOutputStream = new FileOutputStream(filename);

        for (int i = 0; i < strings.length; i++) {
            String string = strings[i];
            fileOutputStream.write((string).getBytes());

            if (i < strings.length) {
                fileOutputStream.write('\n');
            }
        }

        fileOutputStream.close();
    }


    public String[] readFromFile(String filename) throws IOException {

        List<String> lines = new ArrayList<>();
        InputStream inputStream = ResourcesManager.getInstance().activity.getAssets().open(filename);
        int content;
        StringBuilder lineContent = new StringBuilder();

        while ((content = inputStream.read()) != -1) {
            if ((char) content == '\n') {
                lines.add(lineContent.toString());
                lineContent = new StringBuilder();
            } else {
                lineContent.append((char) content);
            }
        }

        if (lineContent.length() != 0) {
            lines.add(lineContent.toString());
        }

        inputStream.close();

        return lines.toArray(new String[lines.size()]);
    }


    public String[] getFilenamesInFolder(String folderPath) {

        String[] fileArray = null;

        try {
            fileArray = context.getAssets().list(folderPath.substring(0, folderPath.length() - 1));
        } catch (IOException e) {
            e.printStackTrace();
        }

        return fileArray;
    }
}

@@ -472,470 +472,8 @@
  %7D%0A%0A
-    public void writeToFile(String filename, String%5B%5D strings) throws IOException %7B%0A%0A        FileOutputStream fileOutputStream = new FileOutputStream(filename);%0A%0A        for (int i = 0; i %3C strings.length; i++) %7B%0A            String string = strings%5Bi%5D;%0A            fileOutputStream.write((string).getBytes());%0A%0A            if (i %3C strings.length) %7B%0A                fileOutputStream.write('%5Cn');%0A            %7D%0A        %7D%0A%0A        fileOutputStream.close();%0A    %7D%0A%0A%0A
     

Remove unused method