jsp读取本服务器utf8编码文件

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*, java.io.*"%>
<%
out.println("开始");
String fileName="d:/tomcat/webapps/cms/test/zucai.txt";
   String output = ""; 
   String sql="";
    File file = new File(fileName);
     int c=0;
     int t=0;
    if(file.exists()){ 
        if(file.isFile()){ 
            try{ 
                  InputStreamReader read = new InputStreamReader (new FileInputStream(file),"UTF-8");
           BufferedReader input = new BufferedReader (read);
                //BufferedReader input = new BufferedReader (new FileReader(file)); 
                StringBuffer buffer = new StringBuffer(); 
                String text;                     
                while((text = input.readLine()) != null){                   
                   // buffer.append(text +"\n");
                String arr[]=text.split("\\t");
                //System.out.println(arr.length);
                if(arr.length==3){
                c++;
               sql="update channel_s3_b_g set name_football='"+tu.SQLQuote(arr[2])+"' where Title='"+tu.SQLQuote(arr[0])+"' and name_en='"+tu.SQLQuote(arr[1])+"' and Status=1";
               out.println(sql);
               out.println("<br/>");
                }
                   //break;
                   t++;
                }                    
               out.println("total="+t);
               out.println("cur="+c);
            } 
            catch(Exception e){ 
             System.out.println("sql="+sql); 
            }
        } 
        else if(file.isDirectory()){ 
            String[] dir = file.list(); 
            output += "Directory contents:\n"; 
             
            for(int i=0; i<dir.length; i++){ 
                output += dir[i] +"\n"; 
            } 
        } 
    } 
    else{ 
    //out.println("文件不存在!"); 
    } 
%>

你可能感兴趣的:(sql,tomcat,c,cms,jsp)