JavaÖжÔÎļþµÄ¸÷ÖÖ²Ù×÷
//java.io
---------------------------------------------------------------
/**
* Title: ÎļþµÄ¸÷ÖÖ²Ù×÷
* Copyright: Copyright (c) 2004
* Company: ¹ã¶« ÓÐÏÞ¹«Ë¾
* @author ÍøÂçÐÅÏ¢²¿ Çì·á
* @version 1.0
*/
package common;
import java.io.*;
public class FileOperate {
public FileOperate() {
}
/**
* н¨Ä¿Â¼
* @param folderPath String Èç c:/fqf
* @return boolean
*/
public void newFolder(String folderPath) {
try {
String filePath = folderPath;
filePath = filePath.toString();
java.io.File myFilePath = new java.io.File(filePath);
if (!myFilePath.exists()) {
myFilePath.mkdir();
}
}
catch (Exception e) {
System.out.println("н¨Ä¿Â¼²Ù×÷³ö´í");
e.printStackTrace();
}
}
/**
* н¨Îļþ
* @param filePathAndName String Îļþ·¾¶¼°Ãû³Æ Èçc:/fqf.txt
* @param fileContent String ÎļþÄÚÈÝ
* @return boolean
*/
public void newFile(String filePathAndName, String fileContent) {
try {
String filePath = filePathAndName;
filePath = filePath.toString();
File myFilePath = new File(filePath);
if (!myFilePath.exists()) {
myFilePath.createNewFile();
}
FileWriter resultFile = new FileWriter(myFilePath);
PrintWriter myFile = new PrintWriter(resultFile);
String strContent = fileContent;
Ïà¹ØÎĵµ£º
finalize·½·¨
ËüÊÇjava.lang.ObjectÀàÖеķ½·¨. ÊÇprotectedµÄ.
ȱʡʱÕâ¸ö·½·¨ÊǿյÄ. JavaÔËÐÐϵͳÔÚÀ¬»ø»ØÊÕʱÔÚ¶ÔÏó±»³·Ïú֮ǰµ÷ÓÃÕâ¸ö·½·¨. µ«ÓÉÓÚÀ¬»øµ¥Ôª
»ØÊÕµÄʱ¼äÊDz»È·¶¨µÄ.ËùÒÔ²»Äܹý·ÖÒÀÀµËü(ÕâºÍc++µÄÎö¹¹º¯Êý²»Í¬).
¶øÖ»ÄÜÊÇ"ÔÚ¶ÔÏó±»³·Ïú֮ǰ"×öһЩ´¦Àí.ÀýÈç¿ÉÒÔÔÚÕâÀï¹Ø±Õ¹¹Ôì·½·¨Öдò¿ ......
cmd
set path=javacËùÔÚÎļþ¼Ð£¨²»°üÀ¨javac)
ÔÚÈÎÒâÎļþ¼ÐÏÂÖ±½ÓʹÓÃjavac.exe,µ«µ±cmd ¹Ø±Õʱ£¬¾Í²»ÔÙÆð×÷ÓÃ
set classpath=...
×÷ÓÃ:ÔÚÈÎÒâÎļþ¼ÐÏÂÖ±½ÓʹÓÃ.classÎļþ£¬µ«µ±cmd ¹Ø±Õʱ£¬¾Í²»ÈðÆð×÷ÓÃ
²é¿´£ºset pathh; set classpath
ÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿ÉèÖÃ
Óû§±äÁ¿£º
±äÁ¿Ãû£ºclasspat ......
import java.util.LinkedList;
//µ¥Ïò¶ÓÁÐ
public class Queue {
public Queue() {
}
private LinkedList list = new LinkedList();
public void pu ......
/*´Ó·þÎñÆ÷ÖÐÏÂÔØÎļþµ½±¾µØ*/
/*url:Îļþ´æ·ÅÔÚ·þÎñÆ÷µÄµØÖ·£»target:Òª±£´æµÄ·¾¶*/
public String DownloadFile(String url,String target){
URLConnection con=null;
URL theUrl=null;
try {
theUrl=new URL(url);//½¨Á¢µØÖ·
......