Subversion Repositories SmartDukaan

Rev

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

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