Jsp used for direct download files function

  Abstract: The realization of direct download files jsp function 

  </ Td> </ tr> <tr> <td width="552" height="35" valign="top" class="ArticleTeitle"> <% 
  / / Sometimes a user wants to download files, but this type of file in the system associated with the browser, the results will become open in IE. 
  / / A common word, excel, such as pdf.    Therefore the documents translated into data flow to its browser does not know the type of document to download purposes. 
  / / Usage: 
  / / Download image 

  String root = getServletContext (). GetRealPath ("/"); 
  String path = request.getParameter ( "path"); 
  String name = request.getParameter ( "name"); 

  Response.setContentType ( "unknown"); 
  Response.addHeader ( "Content-Disposition", "filename = \" "+ name +" \ ""); 

  Try 
  ( 
  Java.io.OutputStream os = response.getOutputStream (); 
  Java.io.FileInputStream fis = new java.io.FileInputStream (root path + + name); 

  Byte [] b = new byte [1024]; 
  Int i = 0; 

  While ((i = fis.read (b))> 0) 
  ( 
  Os.write (b, 0, i); 
  ) 

  Fis.close (); 
  Os.flush (); 
  Os.close (); 
  ) 
  Catch (Exception e) 
  ( 
  ) 
  %> </ Td> <td width="175" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ Back 

Using JSP download word documents (not the direct use of open IE)

  Abstract: JSP download word documents (not the direct use of open IE) 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="684" border="0"> <tr> <td width = " 402 "> <% @ page import =" java.util .*"%> 
  <% @ Page import = "java.io. *"%> 
  <% @ Page import = "java.net .*"%> 

<%
  String filename = ""; 
  If (request.getParameter ( "file")! = Null) ( 
  Filename = request.getParameter ( "file"); 
  ) 

  Response.setContentType ( "application / msword"); 
  Response.setHeader ( "Content-disposition", "attachment; filename =" + filename); 
  </ Td> <td width="272" align="center"> </ td> </ tr> </ table>? 

  BufferedInputStream bis = null; 
  BufferedOutputStream bos = null; 
  Try ( 
  Bis = new BufferedInputStream (new FileInputStream (getServletContext (). GetRealPath ( "/ dir1/dir2 /" + filename))); 
  Bos = new BufferedOutputStream (response.getOutputStream ()); 

  Byte [] = new byte buff [2048]; 
  Int bytesRead; 

  While (-1! = (BytesRead = bis.read (buff, 0, buff.length))) ( 
  Bos.write (buff, 0, bytesRead); 
  ) 
  ) Catch (final IOException e) ( 
  Out.println ( "IOException." + E); 
  Finally () 
  If (bis! = Null) 
  Bis.close (); 
  If (bos! = Null) 
  Bos.close (); 
  ) 
  Return; 
  %> Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore") ; document.getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr> 

  ↑ Back 

JspSmartUpload upload download components

  Abstract: uploading and downloading components jspSmartUpload 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> popular upload download components.    There are examples of usage, types of documents and documentation.    </ Td> </ tr> <tr> 

  ↑ Back 

Download URL content

  Abstract: URL to download the contents of 

  </ Td> </ tr> <tr> <td width="496" height="35" valign="top" class="ArticleTeitle"> / * 
  * Copyright (c) 2000 David Flanagan All rights reserved. 
  * This code is from the book Java Examples in a Nutshell, 2nd Edition. 
  * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. 
  * You may study, use, and modify it for any non-commercial purpose. 
  * You may distribute it non-commercially as long as you retain this notice. 
  * For a commercial use license, or to purchase the book (recommended), 
  * Visit http://www.davidflanagan.com/javaexamples2. 
  * / 
  Import java.io. *; 
  Import java.net .*; 

  / ** 
  * This simple procedure and the use of URL openStream () method to download 
  * URL content and copy the document or in the background. 
  ** / 
  (Public class GetURL 
  Public static void main (String [] args) ( 
  InputStream in = null; 
  OutputStream out = null; 
  Try ( 
  / / Detection parameters 
  If ((args.length! = 1) & (args.length! = 2)) 
  Throw new IllegalArgumentException ( "Wrong number of args"); 

  / / Set the flow 
  URL url = new URL (args [0]); / / create URL 
  Url.openStream in = () / / open a flow 
  If (args.length == 2) / / output access to the corresponding flow 
  Out = new FileOutputStream (args [1]); 
  Else out = System.out; 

  / / URL copy bytes to the output stream 
  Byte buffer [] = new byte [4096]; 
  Int bytes_read; 
  While ((bytes_read = in.read (buffer))! = -1) 
  Out.write (buffer, 0, bytes_read); 
  ) 
  / / On exceptions, the print error message and usage message. 
  Catch (Exception e) ( 
  System.err.println (e); 
  System.err.println ( "Usage: java GetURL  [   ] "); 
  ) 
  Finally (/ / Close always remember flow. 
  Try (in.close (); out.close ();) catch (Exception e) () 
  ) 
  ) 
  ) 


  Operation: 

  C: \ java> java GetURL http://127.0.0.1:8080/zz3zcwbwebhome/ home.html 

  C: \ java> </ td> <td width="188" valign="top" class="ArticleTeitle"> 
  </ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle"> 

  ↑ Back 

The document Java HTTP download queue

  Abstract: The Java HTTP download documents queue 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="730" border="0"> <tr> <td> </ td> </ tr> </ table> 
  Import java.io. *; 
  Import java.net .*; 
  Import java.util .*; 

  / ** 
*

  Title: Personal development of the API 


*

  Description: HTTP will be designated to local network resources in the form of document storage 


*

  Copyright: Copyright (c) 2004 


*

  Company: NewSky 


  * @ Author MagicLiao 
  * @ Version 1.0 
  * / 
  (Public class HttpGet 

  Public final static boolean DEBUG = true; / / debugging 
  Private static int BUFFER_SIZE = 8096; / / Buffer Size 
  Private Vector vDownLoad = new Vector ();// URL List 
  Private Vector vFileList = new Vector ();// after downloading the file name list 

  / ** 
  * Construction 
  * / 
  Public HttpGet () ( 

  ) 

  / ** 
  * Removal Download List 
  * / 
  Public void resetList () ( 
  VDownLoad.clear (); 
  VFileList.clear (); 
  ) 

  / ** 
  * Download List of 
*
  * @ Param url String 
  * @ Param filename String 
  * / 
  Public void addItem (String url, String filename) ( 
  VDownLoad.add (url); 
  VFileList.add (filename); 
  ) 

  / ** 
  * Based on the download list of resources 
  * / 
  Public void downLoadByList () ( 
  String url = null; 
  String filename = null; 

  / / Resource preservation order on List 
  For (int i = 0; i <vDownLoad.size (); i + +) ( 
  Url = (String) vDownLoad.get (i); 
  Filename = (String) vFileList.get (i); 

  Try ( 
  SaveToFile (url, filename); 
  ) 
  Catch (IOException err) ( 
  If (DEBUG) ( 
  System.out.println ( "resources [" + url + "] Download failure !!!"); 
  ) 
  ) 
  ) 

  If (DEBUG) ( 
  System.out.println ( "download !!!"); 

  ) 
  ) 

  / ** 
  * Save the document HTTP resources 
*
  * @ Param destUrl String 
  * @ Param fileName String 
  * @ Throws Exception 
  * / 
  Public void saveToFile (String destUrl, String fileName) throws IOException ( 
  FileOutputStream fos = null; 
  BufferedInputStream bis = null; 
  HttpURLConnection httpUrl = null; 
  URL url = null; 
  Byte [] buf = new byte [BUFFER_SIZE]; 
  Int size = 0; 

  / / Links 
  Url = new URL (destUrl); 
  HttpUrl = (HttpURLConnection) url.openConnection (); 
  / / Connect designated resources 
  HttpUrl.connect (); 
  / / Get input flow network 
  Bis = new BufferedInputStream (httpUrl.getInputStream ()); 
  / / Create documents 
  Fos = new FileOutputStream (fileName); 

  If (this.DEBUG) 
  System.out.println ( "access links are [" + + destUrl "] … \ n will be preserved for its paper [" + + "]"); fileName 

  / / Save the file 
  While ((size = bis.read (buf))! = -1) 
  Fos.write (buf, 0, size); 

  Fos.close (); 
  Bis.close (); 
  HttpUrl.disconnect (); 
  ) 

  / ** 
  * Set up a proxy server 
*
  * @ Param proxy String 
  * @ Param proxyPort String 
  * / 
  Public void setProxyServer (String proxy, String proxyPort) ( 
  / / Set proxy server 
  System.getProperties (). Put ( "proxySet", "true"); 
  System.getProperties (). Put ( "proxyHost" proxy); 
  System.getProperties (). Put ( "proxyPort" proxyPort); 

  ) 

  / ** 
  * Set up user name and password authentication 
*
  * @ Param uid String 
  * @ Param pwd String 
  * / 
  Public void setAuthenticator (String uid, String pwd) ( 
  / / Authenticator.setDefault (new MyAuthenticator (uid, pwd)); 
  ) 

  / ** 
  * The main method (for testing) 
*
  * @ Param argv String [] 
  * / 
  Public static void main (String argv []) ( 

  HttpGet oInstance = new HttpGet (); 
  Try ( 
  / / Increase download list (here users can write their own code to increase the download list), to save downloaded files in the current directory. 
  OInstance.addItem ( "http://java.dhcn.net:8080/softdownload/dir1/dir5/10.zip ","./ Network Programming 1. Zip"); 
  OInstance.addItem ( "http://java.dhcn.net:8080/softdownload/dir1/dir5/10233.zip ","./ Network Programming 2. Zip"); 
  / / OInstance.addItem ( "http://www.ebook.com/java/ Network Programming 003. Zip ","./ network programming 3. Zip"); 
  / / OInstance.addItem ( "http://www.ebook.com/java/ Network Programming 004. Zip ","./ network programming 4. Zip"); 
  / / OInstance.addItem ( "http://www.ebook.com/java/ Network Programming 005. Zip ","./ network programming 5. Zip"); 
  / / OInstance.addItem ( "http://www.ebook.com/java/ Network Programming 006. Zip ","./ network programming 6. Zip"); 
  / / OInstance.addItem ( "http://www.ebook.com/java/ Network Programming 007. Zip ","./ Network Programming 7. Zip"); 
  / / Start the download 
  OInstance.downLoadByList (); 
  ) 
  Catch (Exception err) ( 
  System.out.println (err.getMessage ()); 
  ) 

  ) 

  ) 
  Running Results: 

  C: \ java> javac HttpGet.java 

  C: \ java> java HttpGet 
  Access links are [http://java.dhcn.net:8080/softdownload/dir1/dir5/10.zip] … 
  For the preservation of their documents [. / Network Programming 1. Zip] 
  Access links are [http://java.dhcn.net:8080/softdownload/dir1/dir5/10233.zip] … 
  For the preservation of their documents [. / Network Programming 2. Zip] 
  Download! 

  C: \ java> 
  </ Td> </ tr> <tr> 

  ↑ Back 

Java prepared by the simple download manager (with source code)

  Abstract: java prepared by the simple download manager (with source code) 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> simple download tools, GUI interface, it can download more than one file, and report downloaded bytes few, download progress and completion percentage download status.    Xuchuan breakpoint support, to suspend, resume, cancel the download tasks. 

  This source of four documents: Download.java, DownloadManager.java, DownloadsTableModel.java, ProgressRenderer.java. 
  Commencement of the proceedings: 

  C: \ ja> javac *. java 

  C: \ ja> java DownloadManager 

  <table Width="731" border="0"> <tr> <td> </ td> </ tr> </ table> 
  Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr> 

  ↑ Back 

CLDC API MIDP API source code and download address (including all versions) [job is reposted]

  Abstract: CLDC API MIDP API source code and download address (including all versions) [job is reposted] 

  From: http://tb.blog.csdn.net/TrackBack.aspx?PostId=710117 


  CLDC API source code: 

  Http://www.sun.com/software/communitysource/j2me/cldc/download.xml 

  MIDP API source code: 

  Http://www.sun.com/software/communitysource/j2me/midp/download.xml 

  By studying the source code, you can support or better understanding of the use of these API provides functions. 




  Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=710117 




  ↑ Back 

How do I download JAVA mobile phone games ah?

  Abstract: How do I download JAVA mobile phone games ah? 


  How do I download JAVA mobile phone games ah? Like some people say that can be directly downloaded from the Internet using a mobile phone, ah, how, at what? 



  Monternet, or free wap stations, the Internet found a lot 



  What is your cell phone? 



  If your phone lines and data-storage cards it more convenient, even on the computer, copies of the JAVA games on mobile phones, is generally JAR and JAD files, and then enter the cell phone choose to install the new procedure, can be installed on the game, if not Data lines are, it will only download the Internet using a mobile phone or mobile Monternet site to see, send text messages *****, ***** to be a connection address, phone and Internet downloads. 



  Direct execution on the phone jar files 


  ↑ Back 

Just do a mobile entertainment software, and welcomed everyone to download test to those有分

  Abstract: just do a mobile entertainment software, and welcomed everyone to download test to those有分 


  The main function is to look at online joke 

  Here are details: http://www.seeqi.cn/blog/article.asp?id=26 

  Open mobile phone users point: http://221.217.195.252:9999/ download, dynamic IP address, so constant changes in the latest BLOG address 

  Software is short of a joke, has a revenue of more than 20,000 jokes, this is my first effort, we hope that a lot testing 



  See Bangding 



  In my point above 7360 "humorous joke" when mistakes 



  I also learn that, these days, some support 



  Is pretty good.    .    .    . 




  Access points ~~~~~~~~ 



  I use the e680, humorous joke no access. 



  Will not function keys like ah .. 

  Navigation button "OK" no access? 



  UP to first 



  Access points ~~~~~~~~ 



  Top 




  Support 



  Up 




  Access points 




  Look at the first 

  Support 



  ↑ Back 

Web-based MIDlets profile, the Chinese version (the fiery download!)

  Abstract: Based on the network MIDlets profile, the Chinese version (the fiery download!) 

  <tr> <td> 
  Http:///tech/article669.html 
  [This last posting from SteveQ in 2002/10/28 12:38 pm edit] 

  Download! 
  Http:///tech/article669.html 
  </ Td> </ tr> </ table> </ td> </ tr> <tr> <td background="/pic/split.gif" height=1> </ td> </ tr> <tr> <td class="tdMargin1"> 
  ↑ Back 

keep looking »