package file;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
*
*
* @author ZengWenfeng
* @email 117791303@QQ.COM
* @date 2012.04.12
*/
public class ReadTxtFile
{
/*
* 读文件
*/
public static void readTxt()
{
// 文件和该类在同个目录下
String filePath = TextCharset.class.getResource("").getPath().replace("file:", "") + "/1.txt";
BufferedReader reader = null;
try
{
// 指定读取文件的编码格式,要和写入的格式一致,以免出现中文乱码
reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));
String str = null;
while ((str = reader.readLine()) != null)
{
// System.out.println(str);
//sql.append(" WHERE 1 = 1 ");
System.out.println("sql.append(\" " + str + " \");");
}
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
readTxt();
}
}