請問各位大大,servlet的out.println()中有類似java"\t"的語法嗎?
讀取csv檔,希望可以讓輸出更整齊
謝謝~~
PrintWriter out = response.getWriter();
BufferedReader br = new BufferedReader((new InputStreamReader(ins)));
String line = null;
while((line=br.readLine())!=null){
String item[] = line.split(",");
for(int i=0;i<item.length;i++){
out.print(item[i]+" ");
}
pw.println("<br>");
最基本的寫法
PrintWriter out = response.getWriter();
BufferedReader br = new BufferedReader((new InputStreamReader(ins)));
String line = null;
out.println("<table>");
while((line=br.readLine())!=null){
out.println("<tr>");
String item[] = line.split(",");
for(int i=0;i<item.length;i++){
out.print("<td>"+item[i]+"</td>");
}
out.println("</tr>");
}
out.println("</table>");
是說為什麼最後面是 pw 而不是 out