Subversion Repositories SmartDukaan

Rev

Rev 30728 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30728 Rev 34619
Line 56... Line 56...
56
			}
56
			}
57
			return baos;
57
			return baos;
58
		}
58
		}
59
	}
59
	}
60
 
60
 
-
 
61
	public static ByteArrayOutputStream getCSVByteStreamWithMultiHeaders(List<List<String>> headers, List<List<?>> rows) throws Exception {
-
 
62
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
 
63
		try (PrintStream writer = new PrintStream(baos);
-
 
64
			 CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.EXCEL.withTrim())) {
-
 
65
 
-
 
66
			// Print all header rows manually
-
 
67
			for (List<String> headerRow : headers) {
-
 
68
				csvPrinter.printRecord(headerRow);
-
 
69
			}
-
 
70
 
-
 
71
			// Print all data rows
-
 
72
			for (List<?> row : rows) {
-
 
73
				csvPrinter.printRecord(row);
-
 
74
			}
-
 
75
		}
-
 
76
		return baos;
-
 
77
	}
-
 
78
 
-
 
79
 
61
	public static List<CSVRecord> readFile(MultipartFile file) throws IOException, ProfitMandiBusinessException {
80
	public static List<CSVRecord> readFile(MultipartFile file) throws IOException, ProfitMandiBusinessException {
62
 
81
 
63
		CSVParser parser = new CSVParser(new InputStreamReader(file.getInputStream()), CSVFormat.DEFAULT);
82
		CSVParser parser = new CSVParser(new InputStreamReader(file.getInputStream()), CSVFormat.DEFAULT);
64
		List<CSVRecord> records = parser.getRecords();
83
		List<CSVRecord> records = parser.getRecords();
65
		LOGGER.info("records" + records);
84
		LOGGER.info("records" + records);