日期:2014-05-19 浏览次数:21176 次
String path = CmsContext.projectPath;
String realPath = path + "/index.html";
File file = new File(realPath);
/* DEL */
//System.out.println("#####:"+ realPath);
if(file.exists() || file.isDirectory()){
System.out.println("首页面可编辑... ");
/** 将html内容读取出来 */
try {
BufferedInputStream in = new BufferedInputStream(
new FileInputStream(file));
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;
while ((size = in.read(temp)) != -1) {
out.write(temp, 0, size);
}
in.close();
/* DEL */
//String clob = new String(out.toString().getBytes("iso8859-1"),"GB2312");
String encod_char = out.toString();
/**
*
*/
package encodingTest;
/**
* @author wkupaochuan
* @time Apr 11, 2012
* @version V 1.0
*/
import java.io.*;
public class Test {
public static void main (String agrs[]) throws IOException
{
File f = new File("C://1.html");
BufferedInputStream in = new BufferedInputStream(
new FileInputStream(f));
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;
while ((size = in.read(temp)) != -1) {
out.write(temp, 0, size);
}
in.close();
String encod_char = out.toString();
System.out.println(encod_char);
}
}
------解决方案--------------------
html源码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>实验</head>
<body>
主题
</body>
</html>