public final class CsvFileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
formatKommaSeperatedFileToList(File input,
String encoding)
Reads every line from the File splits the data through a comma and puts them to the List.
|
static void |
formatToCSV(File input,
File output,
String encoding)
Formats a file that has in every line one input-data into a csv-file.
|
static List<Map<String,String>> |
getCvsAsListMap(File input)
Gets the given cvs file as list of maps.
|
static String[] |
getDataFromLine(String line,
String seperator)
Gets the data from line.
|
static String[] |
getDataFromLine(String line,
String seperator,
boolean trim)
Gets the data from line.
|
static int |
getLineCountFromCsvFile(File file)
Gets the line count from csv file.
|
static List<String> |
readDataFromCVSFileToList(File input,
int position,
boolean putFirstLine,
String encoding)
Reads from a csv-file the field from the given position and puts them to the List.
|
static List<String> |
readDataFromCVSFileToList(File input,
int position,
boolean putFirstLine,
String splitChar,
String encoding)
Reads from a csv-file the field from the given position and puts them to the List.
|
static Properties |
readFilelistToProperties(File input)
Read filelist to properties.
|
static List<String> |
readFileToList(File file)
Reads every line from the given File into a List and returns the List.
|
static List<String> |
readFileToList(File file,
String encoding)
Reads every line from the given File into a List and returns the List.
|
static List<String[]> |
readFileToList(File file,
String seperator,
String encoding)
Reads every line from the given File into a List of String arrays and returns the List.
|
static List<String> |
readLinesInList(File input,
String encoding)
Reads every line from the File and puts them to the List.
|
static String[] |
sortData(File csvData,
String encoding)
Read an csv-file and puts them in a String-array.
|
static void |
storeFilelistToProperties(File output,
File input,
String comments)
Stores a komma seperated file to a properties object.
|
static void |
writeLines(File output,
Set<String> values,
String encoding)
Writes the toString() value of each item in a collection to the specified File line by line.
|
static void |
writeLinesToFile(Collection<String> collection,
File output,
String encoding)
Writes all the String-object in the collection into the given file.
|
public static List<String> formatKommaSeperatedFileToList(File input, String encoding)
input - The File from where the input comes.encoding - The encoding from the file.public static void formatToCSV(File input, File output, String encoding) throws IOException
input - The input-file to format. The current format from the file is every data in a
line.output - The file where the formatted data should be inserted.encoding - the encodingIOException - When an io error occurs.public static List<Map<String,String>> getCvsAsListMap(File input) throws IOException
input - the inputIOException - Signals that an I/O exception has occurred.public static String[] getDataFromLine(String line, String seperator)
line - the lineseperator - the seperatorpublic static String[] getDataFromLine(String line, String seperator, boolean trim)
line - the lineseperator - the seperatortrim - the trimpublic static int getLineCountFromCsvFile(File file) throws IOException
file - the fileIOException - Signals that an I/O exception has occurred.public static List<String> readDataFromCVSFileToList(File input, int position, boolean putFirstLine, String encoding) throws IOException
input - The input-file.position - The position from the field.putFirstLine - Flag that tells if the first line will be put in the list.encoding - the encodingIOException - When a io-problem occurs.public static List<String> readDataFromCVSFileToList(File input, int position, boolean putFirstLine, String splitChar, String encoding) throws IOException
input - The input-file.position - The position from the field.putFirstLine - Flag that tells if the first line will be put in the list.splitChar - the split charencoding - the encodingIOException - When a io-problem occurs.public static Properties readFilelistToProperties(File input) throws IOException
input - the inputIOException - Signals that an I/O exception has occurred.public static List<String> readFileToList(File file) throws IOException
file - The file from where to read.IOException - When a io-problem occurs.public static List<String> readFileToList(File file, String encoding) throws IOException
file - The file from where to read.encoding - The encoding to read.IOException - When a io-problem occurs.public static List<String[]> readFileToList(File file, String seperator, String encoding) throws IOException
file - The file from where to read.seperator - the seperatorencoding - The encoding to read.IOException - Signals that an I/O exception has occurred.public static List<String> readLinesInList(File input, String encoding) throws IOException
input - The File from where the input comes.encoding - The encoding from the file.IOException - When a io-problem occurs.public static String[] sortData(File csvData, String encoding) throws FileNotFoundException, IOException
csvData - The csv-file with the data.encoding - The encoding to read.FileNotFoundException - the file not found exceptionIOException - When an io-error occurs.public static void storeFilelistToProperties(File output, File input, String comments) throws IOException
output - the outputinput - the inputcomments - the commentsIOException - Signals that an I/O exception has occurred.public static void writeLines(File output, Set<String> values, String encoding) throws IOException
output - The File where the values to save.values - The Set with the values to put into the file.encoding - The encoding from the file.IOException - When a io-problem occurs.public static void writeLinesToFile(Collection<String> collection, File output, String encoding)
collection - The collection with the String-object.output - The file where the String-object will be writing.encoding - The encoding from the file.Copyright © 2007–2015 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.