Project

General

Profile

Revision a021842d

IDa021842d3efd76265aa04b401c8f1820b3fcbb7d
Parent 754e5a32
Child 9e5c772a

Added by Alexander Oppermann over 7 years ago

fixed character encoding

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/csv/CsvExportController.java
12 12
import java.io.ByteArrayOutputStream;
13 13
import java.io.File;
14 14
import java.io.InputStreamReader;
15
import java.io.PrintWriter;
15 16
import java.util.ArrayList;
16 17
import java.util.Arrays;
17 18
import java.util.HashSet;
......
113 114
			 *  
114 115
			 *  HTPP Error Break
115 116
			 */
116
			ByteArrayInputStream bais = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
117
			InputStreamReader isr = new InputStreamReader(bais, "UTF-8");
118
			ServletOutputStream sos = response.getOutputStream();
117
			ByteArrayInputStream bais = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());//byteArrayOutputStream.toByteArray()
118
			InputStreamReader isr = new InputStreamReader(bais);
119 119
			Cookie progressCookie = new Cookie("fileDownloadToken", downloadTokenValueId);
120 120
			progressCookie.setPath("/");
121 121
			progressCookie.setMaxAge(60);
122 122
			response.addCookie(progressCookie);
123 123
			response.setContentType("text/csv; charset=utf-8");
124 124
			response.setHeader("Content-Disposition", "attachment; filename=\""+config.getClassificationTitleCache()+".txt\"");
125
			PrintWriter printWriter = response.getWriter();
125 126

  
126 127
			int i;
127 128
			while((i = isr.read())!= -1){
128
				sos.write(i);
129
				printWriter.write(i);
129 130
			}
130 131
			byteArrayOutputStream.flush();
131 132
			isr.close();
132 133
			byteArrayOutputStream.close();
133
			sos.flush();
134
			sos.close();
134
			printWriter.flush();
135
			printWriter.close();
135 136
		} catch (Exception e) {
136 137
			logger.error("error generating feed", e);
137 138
		}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)