Subversion Repositories SmartDukaan

Rev

Rev 23951 | Rev 24809 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23951 Rev 24593
Line 44... Line 44...
44
	public static void main(String[] args) {
44
	public static void main(String[] args) {
45
		// detectFileType(new File("/hsps-docs/1499163441532"));
45
		// detectFileType(new File("/hsps-docs/1499163441532"));
46
		// System.out.println("he");
46
		// System.out.println("he");
47
	}
47
	}
48
 
48
 
49
	public static ByteArrayOutputStream getCSVByteStream(List<String> headers, List<List<Object>> rows) throws Exception {
49
	public static ByteArrayOutputStream getCSVByteStream(List<String> headers, List<List<?>> rows) throws Exception {
50
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
50
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
51
				PrintStream writer = new PrintStream(baos);
51
				PrintStream writer = new PrintStream(baos);
52
				CSVPrinter csvPrinter = new CSVPrinter(writer,
52
				CSVPrinter csvPrinter = new CSVPrinter(writer,
53
						CSVFormat.EXCEL.withTrim().withHeader(headers.toArray(new String[] {})));) {
53
						CSVFormat.EXCEL.withTrim().withHeader(headers.toArray(new String[] {})));) {
54
			for (List<Object> row : rows) {
54
			for (List<?> row : rows) {
55
				csvPrinter.printRecord(row);
55
				csvPrinter.printRecord(row);
56
			}
56
			}
57
			return baos;
57
			return baos;
58
		}
58
		}
59
	}
59
	}