Skip to content

Instantly share code, notes, and snippets.

@Butch78
Last active October 15, 2017 11:13
Show Gist options
  • Save Butch78/cb4e8785e81574a60cae246a92d32623 to your computer and use it in GitHub Desktop.
Save Butch78/cb4e8785e81574a60cae246a92d32623 to your computer and use it in GitHub Desktop.
TempJava
package swindroid.suntime.calc;
import android.content.res.Resources;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import swindroid.suntime.R;
/**
* Created by Matthew on 28/09/2017.
*/
public class CSVFile {
private InputStream auInputStream;
private InputStream addedInputStream;
private OutputStream outputStream;
public CSVFile(InputStream auInputStream, InputStream addedInputStream, OutputStream outputStream)
{
this.auInputStream = auInputStream;
this.addedInputStream = addedInputStream;
this.outputStream = outputStream;
}
public ArrayList<String[]> readFiles(InputStream inputStream)
{
ArrayList<String []> resultList = new ArrayList<String[]>();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
try
{
String csvLine;
while ((csvLine = reader.readLine()) != null) {
String[] row = csvLine.split(",");
resultList.add(row);
}
}
catch(IOException ex)
{
throw new RuntimeException("Error in CSV file" +ex);
}
finally {
try{
inputStream.close();
}
catch (IOException e)
{
throw new RuntimeException("Error while closing stream:"+e);
}
}
return resultList;
}
public ArrayList<String[]> read()
{
ArrayList<String []> temp = readFiles(auInputStream);
ArrayList<String []> resultList = new ArrayList<String[]>();
resultList.addAll(temp);
temp = readFiles(addedInputStream);
resultList.addAll(temp);
return resultList;
}
public void write(GeoLocation geoLocation)
{
ArrayList<String []> resultList = new ArrayList<String[]>();
OutputStream writer =
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment