[Original] Publish my own source code for generating HTML files yourself!

xiaoxiao2021-03-06  41

Package gdbye.com.io;

import java.io *;. import java.util *;. import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.PageContext; import java.lang *;. import gdbye.com .basice. *; // A basic import gdbye.com.date.newcom. *; import com.NTsky.File.FileUtil; // I am mainly used here. Generate a directory, need to contact

Public class orelse {/ * I have written too messy I am too chaotic! Please contact gdbye.com if you have any questions. <- This package is my class * /

private Map map = new HashMap (); private String root_jsp = ""; private String FileNameRet = ""; private String FIleNmae = ""; private String NameFirst = ""; private String MuFile_root = ""; private String Class_root = "" ; private String SetFileRom = ""; private boolean creatFile = false; private String FullMUFile_root = ""; private ArrayList PostList = null; public void IOElse_Map (int replaceInt, String Outleft) {

Try {basecount b = new basecount (); for (int i = 1; i <= replaceint; i ) {if (i <= 9) map.put (Namefirst "0" i Outleft, B.Convert (String) PostList.get (I-1)))); Else Map.Put (Namefirst i Outleft, B.Convert ((String) PostList.get (I-1))));}} Catch (Exception E) {E.PrintStackTrace (); Return;}

}

Public void setArrayList (arraylist stn) {

This.PostList = STN;}

/ *

Initialization Variables setRepalCename: The object started to find the SOUBILSETFILENAME: The generated file name MubilSetFileroot: File generated path initialize: get the directory path getAutofileName (str, endst): Bring a new file name with the str, Endst end

* /

Public void setRepalCename (String Str) {

THIS.NAMEFIRST = STR;

}

Public void setclass_root (string str) {this.class_root = STR;

}

Public void Souse_setFileName (String file_name) {this.filenameret = file_name;}

Public void mubilsetFileName (string file_name) {

This.FileNMAE = file_name;

}

Public void mubilsetfileroot (string strroot) {

BaseCount b = new BaseCount (); if (b.EmptyStr (strRoot)) this.MuFile_root = Class_root strRoot; else {GregorianCalendar d = new GregorianCalendar (); this.MuFile_root = Class_root d.get (Calendar.YEAR) "-" (D.Get (Calendar.Mont) 1) "-" D.Get (Calendar.day_of_month);

}

Public void initialize (string url) {

THIS.ROOT_JSP = URL;}

Public void initialize (pageContext pageContext) {

THIS.ROOT_JSP = PageContext.getServletContext (). getRealPath ("/");}

Public string getautofilename (string start, string endstr) {Gregoriancalendar D = new gregoriancalendar (); return start "_" D.Get (Calendar.Year) (D.Get (Calendar.Mont) 1) D.Get (Calendar.day_of_month) D.Get (Calendar.Hour) D.Get (Calendar.minute) D.Get (Calendar.Second) "." EndStr;

}

/ *

Return Data Get_MubilSetFileName: Return to Generate File Name Get_MubilSetFileName: Return to File Path GetSetFileroM: Return to Generate File * /

Public string get_mubilsetFileName () {

Return this.filenmae;

}

Public string get_mubilsetfileroot () {

Return this.mufile_root;

}

Public string getsetfilerom () {

Return this.setfilero;

}

Public string Sour_file () {

Return root_jsp filenameret;

}

Public string get_fullmufile_root () {

Return Fullmufile_Root;

}

Public string get_full_root_filename () {

String fem_d = mufile_root; if (! Mufile_root.endswith ("/")) Fild_D = "/"; returnifilename ();}

/ *

Generate content

* /

public boolean TextSubcut () {try {boolean return_fun = true; String FileName = root_jsp FileNameRet; BaseCount a = new BaseCount (); String FileRom = ""; File myFile = new File (FileName); String temp = ""; if (myFile.exists ()) {InputStreamReader in = new InputStreamReader (new FileInputStream (myFile), "GB2312"); BufferedReader br = new BufferedReader (in); temp = br.readLine (); int tempInt = 0; int tempOut = 0; while (Temp! = Null) {Tempint = Temp.indexof (Namefirst, Tempint); While (Tempint! = -1) {filerom = Temp.substring (Tempout, Tempint) GetString (Temp.Substring (Tempint, Tempint Namefirst.Length () 3)); Tempout = Tempint NameFirst.Length () 3; if (Tempout> = Temp.Length ()) {Tempint = -1;} else tempint = Temp.indexof (Namefirst , Tempout);} IF (Tempout <= Temp.Length ()) Filerm = Temp.substring (Tempout) "/ N"; Else FileM = "/ N"; tempint = 0; tempout = 0; Temp = Br.readline (); br.close ();} else {return_f Un = false;} this.setfilerom = filerm; returnced (ieException e) {system.out.println (E.getMessage ()); return false;}}

/ *

Generate files

* /

Public void creatfile () {try {

FileOutputStream fos = new FileOutputStream (FullMUFile_root FIleNmae); Writer out = new OutputStreamWriter (fos, "GB2312"); out.write (SetFileRom); out.close (); fos.close (); this.creatFile = true;} Catch (IOException E) {system.out.println (E.getMessage ());}}

Public void createdir () {Try {Gregoriancalendar D = new gregoriancalendar ();

FileUTIL C = new fileutil (); string fem_d = mufile_root; if (! Mufile_root.endswith ("/")) Fild_D = "/"; // if () // Fild_d = D.Get (Calendar.Year) "-" " D.GET (Calendar.mont) " - " D.Get (Calendar.day_of_month); c.makedir (Fild_D, Root_JSP); this.FullMufile_Root = root_jsp Fild_D;

} catch (exception e) {

}

Public map getInputmap () {return this.map;} public string getstring (string key) {// TODO automatic generation method Store Return (String) map.get (kEy);}

}

转载请注明原文地址:https://www.9cbs.com/read-60581.html

New Post(0)