Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ʵÏÖÏÂÔØ¹¦ÄÜ

/**
* ÏÂÔØÎļþ
* @param filePath --ÎļþÍêÕû·¾¶
* @param response --HttpServletResponse¶ÔÏó
*/
public static void downloadFile(
String filePath,
javax.servlet.http.HttpServletResponse response) {
String fileName = ""; //ÎļþÃû£¬Êä³öµ½Óû§µÄÏÂÔØ¶Ô»°¿ò
//´ÓÎļþÍêÕû·¾¶ÖÐÌáÈ¡ÎļþÃû£¬²¢½øÐбàÂëת»»£¬·ÀÖ¹²»ÄÜÕýÈ·ÏÔʾÖÐÎÄÃû
try {
if(filePath.lastIndexOf("/") > 0) {
fileName = new String(filePath.substring(filePath.lastIndexOf("/")+1, filePath.length()).getBytes("GB2312"), "ISO8859_1");
}else if(filePath.lastIndexOf("\\") > 0) {
fileName = new String(filePath.substring(filePath.lastIndexOf("\\")+1, filePath.length()).getBytes("GB2312"), "ISO8859_1");
}
}catch(Exception e) {}
//´ò¿ªÖ¸¶¨ÎļþµÄÁ÷ÐÅÏ¢
FileInputStream fs = null;
try {
fs = new FileInputStream(new File(filePath));
}catch(FileNotFoundException e) {
e.printStackTrace();
return;
}
//ÉèÖÃÏìӦͷºÍ±£´æÎļþÃû
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
//д³öÁ÷ÐÅÏ¢
int b = 0;
try {
PrintWriter out = response.getWriter();
while((b=fs.read())!=-1) {
out.write(b);
}
fs.close();
out.close();
System.out.println("ÎļþÏÂÔØÍê±Ï.");
}catch(Exception e) {
e.printStackTrace();
System.out.println("ÏÂÔØÎļþʧ°Ü!");
}
}
·½·¨ÔÚ±íÏÖ²ãÀïµ÷Ó㬱ÈÈçStruts»òServletÀï¡£


Ïà¹ØÎĵµ£º

JAVAÐéÄâ»úµÄÌåϵ½á¹¹

         
ÔÚJava
ÐéÄâ»úµÄ¹æ·¶Öж¨ÒåÁËһϵÁеÄ×Óϵͳ¡¢ÄÚ´æÇøÓò¡¢Êý¾ÝÀàÐͺÍʹÓÃÖ¸ÄÏ¡£ÕâЩ×é¼þ¹¹³ÉÁËJava
ÐéÄâ»úµÄÄÚ²¿½á¹¹£¬ËûÃDz»½ö½öΪJava
ÐéÄâ»úµÄʵÏÖÌṩÁËÇåÎúµÄÄÚ²¿½á¹¹£¬¸üÊÇÑϸñ¹æ¶¨ÁËJava
ÐéÄâ»úʵÏÖµÄÍⲿÐÐΪ¡£ 
    
Ã¿Ò ......

javaÖÐʹÓÃdom4jдxmlÎļþºÍ¼òµ¥½Ì³Ì

 
ÏÂÔØ dom4j-1.6.1.jar¡£
1: package org.zzp.common.xml.dom4j;
2:
3: import java.io.FileWriter;
4: import java.io.IOException;
5: import org.dom4j.Document;
6: import org.dom4j.DocumentHelper;
7: import org.dom4j.Element;
8: import org.dom4j.io.OutputFormat;
9: impor ......

JSON JavaÓëAJAX(Jquery)

Ò»¡¢JSON ÊÇʲô£¿
JSON µÄÈ«³ÆÊÇJavaScript Object Notation£¬ÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ¡£
JSON ÓëXML ¾ßÓÐÏàͬµÄÌØÐÔ£¬ÀýÈçÒ×ÓÚÈ˱àдºÍÔĶÁ£¬Ò×ÓÚ»úÆ÷Éú³ÉºÍ½âÎö¡£µ«ÊÇJSON ±È
XML Êý¾Ý´«ÊäµÄÓÐЧÐÔÒª¸ß³öºÜ¶à¡£JSON ÍêÈ«¶ÀÁ¢Óë±à³ÌÓïÑÔ£¬Ê¹ÓÃÎı¾¸ñʽ±£´æ¡£
JSON Êý¾ÝÓÐÁ½Öֽṹ£º
• Name-Value ¶Ô¹¹³ÉµÄ¼¯ ......

ÈçºÎ ʹÓà java ²Ù×Ý XML Îļþ


Introduction to XML and XML With Java  
 
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xer ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ