ÎļþÏÂÔØ £¨java£©×Ô¼ºµÄһЩ×ܽá
package com.down.servlet;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class DownServlet
*/
public class DownServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DownServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
File downFile = new File ("c:\\OriRevision.doc");
InputStream is = new FileInputStream(downFile);
response.setContentType("text/plain;charset=UTF-8");
response.setBufferSize(100 * 1024);
BufferedInputStream bufInputStream = null;
response.setHeader("Cache-Control", "public");
ServletOutputStream os = response.getOutputStream();
//ÉèÖÃÏÖÔÚwordÕýÎĵÄÏà¹ØÐÅÏ¢
response.setHeader("Content-Disposition", "inline; filename="+ URLEncoder.encode("test.doc", "UTF-8"));
if(is != null){
byte[] b = new byte[10240];
int index = 0;
os = response.getOutputStream();
bufInputStream = new BufferedInputStream(is);
while((index = bufInputStream.read(b)) != -1){
os.write(b, 0, index);
}
response.flushBuffer();
}
}
}
Ïà¹ØÎĵµ£º
61.Îļþ¼ÐÒÆ¶¯µ½ÕûºÏ²Ù×÷
/*
import java.io.*;
import java.util.*;
import javax.swing.*;
*/
JFileChooser Jfc = new JFileChooser("ÇëÑ¡ÔñԴ·¾¶"); // ½¨Á¢Ñ¡Ôñµµ°¸¶Ô»°
·½¿éºÐ Jfc
if (!Jfc.isFileSelectionEnabled()) {
return;
} ......
Àࣺ
·ÃÎÊÐÞÊηû
ÐÞÊηû
class
ÀàÃû³Æ
extends
¸¸ÀàÃû³Æ
implement
½Ó¿ÚÃû³Æ
£¨·ÃÎÊÐÞÊηûÓëÐÞÊηûµÄλÖÿÉÒÔ»¥»»£©
·ÃÎÊÐÞÊηû
Ãû³Æ
˵Ã÷
±¸×¢
public
¿ÉÒÔ±»ËùÓÐÀà·ÃÎÊ£¨Ê¹Óã©
publicÀà±ØÐ붨ÒåÔÚºÍÀàÃûÏàͬµÄͬÃûÎļþÖÐ
package
¿ÉÒÔ±»Í¬Ò»¸ö°üÖеÄÀà·ÃÎÊ£¨Ê¹Óã©
ĬÈϵķÃÎ ......
(1) ÀàÃûÊ××ÖĸӦ¸Ã´óд¡£×ֶΡ¢·½·¨ÒÔ¼°¶ÔÏ󣨾ä±ú£©µÄÊ××ÖĸӦСд¡£¶ÔÓÚËùÓбêʶ·û£¬ÆäÖаüº¬µÄËùÓе¥´Ê¶¼Ó¦½ô¿¿ÔÚÒ»Æð£¬¶øÇÒ´óдÖм䵥´ÊµÄÊ××Öĸ¡£ÀýÈ磺
ThisIsAClassName
thisIsMethodOrFieldName
ÈôÔÚ¶¨ÒåÖгöÏÖÁ˳£Êý³õʼ»¯×Ö·û£¬Ôò´ ......
Õâ¶¼ÊÇÎÒѧϰJAVAÇ×Éí¾ÀúµÄÐĵ㬽ñÌ컨ÁËÒ»¸ö¶àСʱ×ܽá³öÀ´Ï£Íû¶Ô´ó¼ÒÓÐÒ»¶¨µÄ°ïÖú¡£Èç¹ûÈç×ܽ᲻Í×£¬ÇëÖ¸³öºÍÅúÆÀ£¡ÎªÑ§Ï°JAVAµÄ³õѧÕ߯ÌÌõѧϰJAVAµÄµÀ·
Ê×ÏÈ´ó¼ÒÒªÃ÷È·Ò»µã£¬ÍâÃæÕÐÆ¸JAVAµÄ£¬Ö÷ÒªÊÇÖ¸µÄJ2EE£¬Ò²¾ÍÊÇBS½á¹¹£¨ä¯ÀÀÆ÷ºÍ·þÎñÆ÷½á¹¹£©JAVAµÄÖ®ËùÒÔ»ðÆðÀ´ÕæÊÇÒòΪBS½á¹¹£¬²¢²»ÔÚCS½á¹¹£¬ËùÒÔÄÇÖÖ´óÐÍÍøÓÎ ......
¡¾IT168 ¼¼ÊõÎĵµ¡¿
¡¡¡¡/*
¡¡¡¡ÍøÒ³ÖÐµÄ±íµ¥Ê¹ÓÃPOST·½·¨Ìύʱ£¬Êý¾ÝÄÚÈݵÄÀàÐÍÊÇ application/x-www-form-urlencoded£¬ÕâÖÖÀàÐͻ᣺
¡¡¡¡1.×Ö·û"a"-"z"£¬"A"-"Z"£¬"0"-"9"£¬"."£¬"-"£¬"*"£¬ºÍ"_" ¶¼²»»á±»±àÂë;
¡¡¡¡2.½«¿Õ¸ñת»»Îª¼ÓºÅ (+) ;
¡¡¡¡3.½«·ÇÎı¾ÄÚÈÝת»»³É"%xy"µÄÐÎʽ,xyÊÇÁ½Î»16½øÖƵÄÊýÖµ;
¡¡¡¡4.ÔÚ ......