I created a CSVReader and I am trying to read a csv file from assets, so I have to use InputStream. But my code below does not have an input constructor. Can someone tell me how I can add or change something in the code, so I can use the input stream.
public class CSVReader { private BufferedReader br; private boolean hasNext = true; private char separator; private char quotechar; private int skipLines; private boolean linesSkiped; public int linesCount = 0; public static final char DEFAULT_SEPARATOR = '|'; public static final char DEFAULT_QUOTE_CHARACTER = '"'; public static final int DEFAULT_SKIP_LINES = 0; public CSVReader(Reader reader) { this(reader, DEFAULT_SEPARATOR, DEFAULT_QUOTE_CHARACTER, DEFAULT_SKIP_LINES); } public CSVReader(Reader reader, char separator, char quotechar, int line) { this.br = new BufferedReader(reader); this.separator = separator; this.quotechar = quotechar; this.skipLines = line; } public String[] readNext() throws IOException { String nextLine = getNextLine(); return hasNext ? parseLine(nextLine) : null; } public String getNextLine() throws IOException { if (!this.linesSkiped) { for (int i = 0; i < skipLines; i++) { br.readLine(); } this.linesSkiped = true; } String nextLine = br.readLine(); if (nextLine == null) { hasNext = false; } return hasNext ? nextLine : null; } public List<String[]> readAll() throws IOException { List<String[]> allElements = new ArrayList<String[]>(); while (hasNext) { String[] nextLineAsTokens = readNext(); if (nextLineAsTokens != null) allElements.add(nextLineAsTokens); } return allElements; } private String[] parseLine(String nextLine) throws IOException { if (nextLine == null) { return null; } List<String> tokensOnThisLine = new ArrayList<String>(); StringBuffer sb = new StringBuffer(); boolean inQuotes = false; do { if (inQuotes) {
source share