?? writehtmlll.java
字號:
package com.v246;
import java.io.*;
public class WriteHtmlll
{
public WriteHtmlll()
{
}
public static String save(String s, String s1, String s2) throws Exception//完整的HTML內容,s1:目錄(欄目),s2:文件名
{
String a="1024";
// a=System.getProperty("file.separator");
Path path=new Path();
try
{
a=path.getPathFromClass(Path.class); //得到Path.class類的全路徑
}
catch(Exception e)
{
throw new Exception(e.getMessage());
}
StringBuffer str=new StringBuffer(a);
str.replace(a.indexOf("\\WEB-INF\\classes"),a.length(),"");//得到虛擬空間上的網站路徑
str.append(s1+"\\");//在后面加上\
s1=str.toString();//轉換成字符串型
try
{
a(s1);//看看有沒有指定的目錄,如果沒有,則建一個!
FileOutputStream fileoutputstream = new FileOutputStream(s1 + s2);//建立文件
byte abyte0[] = s.getBytes();//將字符串型的數據轉換成BYTE型的
fileoutputstream.write(abyte0);//將剛剛轉換完成的BYTE數組寫入到文件中
fileoutputstream.close();//關閉文件流
//System.out.println(s1+s2);
}
catch (IOException e)
{
System.out.println("write html error" + e.getMessage());
throw new Exception(e.getMessage());
}
a=a+"#########"+s1;
return a;
}
private static void a(String s)
{
try
{
File file = new File(s); //建立文件
if (!file.exists())//如果沒有指定目錄
file.mkdirs();//建一個
}
catch (Exception e)
{
System.out.println("mkdirs error!" + e.getMessage());
}
}
public static void main(String []args)
{
String a;
a=System.getProperty("file.separator");
Path path=new Path();
try
{
a=path.getPathFromClass(Path.class);
}
catch(Exception e)
{
}
StringBuffer str=new StringBuffer(a);
str.replace(a.indexOf("\\WEB-INF\\classes"),a.length(),"");
System.out.println(str);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -