001: /* Filedownload.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Mon Apr 16 14:41:22 2007, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zhtml;
020:
021: import java.io.InputStream;
022: import java.io.Reader;
023:
024: import org.zkoss.util.media.Media;
025:
026: /**
027: * File download utilities.
028: *
029: * @author tomyeh
030: */
031: public class Filedownload {
032: /** Open a download dialog to save the specified content at the client.
033: */
034: public static void save(Media media) {
035: org.zkoss.zul.Filedownload.save(media);
036: }
037:
038: /** Open a download dialog to save the specified content at the client
039: * with the suggested file name.
040: *
041: * @param media the media to download
042: * @param flnm the suggested file name, e.g., myfile.pdf.
043: * If null, {@link Media#getName} is assumed.
044: */
045: public static void save(Media media, String flnm) {
046: org.zkoss.zul.Filedownload.save(media, flnm);
047: }
048:
049: /** Open a download dialog to save the specified content at the client
050: * with the suggested file name.
051: *
052: * @param content the content
053: * @param contentType the content type (aka., mine type),
054: * e.g., application/pdf
055: * @param flnm the suggested file name, e.g., myfile.pdf.
056: * If null, no suggested name is provided.
057: */
058: public static void save(byte[] content, String contentType,
059: String flnm) {
060: org.zkoss.zul.Filedownload.save(content, contentType, flnm);
061: }
062:
063: /** Open a download dialog to save the specified content at the client
064: * with the suggested file name.
065: *
066: * @param content the content
067: * @param contentType the content type (aka., mine type),
068: * e.g., application/pdf
069: * @param flnm the suggested file name, e.g., myfile.pdf.
070: * If null, no suggested name is provided.
071: */
072: public static void save(String content, String contentType,
073: String flnm) {
074: org.zkoss.zul.Filedownload.save(content, contentType, flnm);
075: }
076:
077: /** Open a download dialog to save the specified content at the client
078: * with the suggested file name.
079: *
080: * @param content the content
081: * @param contentType the content type (aka., mine type),
082: * e.g., application/pdf
083: * @param flnm the suggested file name, e.g., myfile.pdf.
084: * If null, no suggested name is provided.
085: */
086: public static void save(InputStream content, String contentType,
087: String flnm) {
088: org.zkoss.zul.Filedownload.save(content, contentType, flnm);
089: }
090:
091: /** Open a download dialog to save the specified content at the client
092: * with the suggested file name.
093: *
094: * @param content the content
095: * @param contentType the content type (aka., mine type),
096: * e.g., application/pdf
097: * @param flnm the suggested file name, e.g., myfile.pdf.
098: * If null, no suggested name is provided.
099: */
100: public static void save(Reader content, String contentType,
101: String flnm) {
102: org.zkoss.zul.Filedownload.save(content, contentType, flnm);
103: }
104: }
|