易截截图软件、单文件、免安装、纯绿色、仅160KB

Flex Java 上传 下载 组件

Flex Java 上传 下载 组件 收藏
事前准备就是到http://commons.apache.org下载common-fileupload-1.1.1.jar以及common-io-1.2.jar两个包。
前台Flex代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" creationComplete="init();">
<mx:Script>
<![CDATA[
import flash.net.FileReference;
import mx.controls.Alert;
import mx.events.CloseEvent;
import flash.events.*;
private var file: FileReference;
private function init(): void{
Security.allowDomain("*");
file = new FileReference();
file.addEventListener(ProgressEvent.PROGRESS, onProgress);
file.addEventListener(Event.SELECT, onSelect);
file.addEventListener(Event.COMPLETE, completeHandle);
}
private function completeHandle(event:Event):void{
     Alert.show("恭喜你,上传成功");
}
private function upload(): void{
var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.png)", "*.jpg;*.jpeg;*.png");
var allTypes:Array = new Array(imageTypes);
file.browse(allTypes);
file.browse();
}
private function onSelect(e: Event): void{
Alert.show("上传 " + file.name + " (共 "+Math.round(file.size)+" 字节)?",
"确认上传",
Alert.YES|Alert.NO,
null,
proceedWithUpload);
}
private function onProgress(e: ProgressEvent): void{
lbProgress.text = " 已上传 " + e.bytesLoaded
+ " 字节,共 " + e.bytesTotal + " 字节";
var proc: uint = e.bytesLoaded / e.bytesTotal * 100;
bar.setProgress(proc, 100);
bar.label= "当前进度: " + " " + proc + "%";
}
private function proceedWithUpload(e: CloseEvent): void{
if (e.detail == Alert.YES){
var request: URLRequest = new URLRequest("http://localhost:8080/FileUploaded/FileUploaded");
try {
file.upload(request);
} catch (error:Error) {
trace("上传失败");
}
}
}
]]>
</mx:Script>
<mx:Canvas width="100%" height="100%" x="10" y="170" fontSize="15">
<mx:VBox width="100%" horizontalAlign="center">
<mx:Label id="lbProgress" te


相关文档:

Java NIO API详解

 
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......

Java SE Static Inner

/*内部类使用示例*/
package demo;
class Outer{
 int outer_i=100;
 static int outer_j=200;
 final int outer_k=300;
 void test(){
  Inner in = new Inner();
  in.display();
 }
 static class Inner{
  void display(){
    ......

Java SE 多态

/*多态示例*/
package demo;
class AA {
 public void f(){
  System.out.println("f in AA");
 }
}
class BB extends AA{
 public void f(){
  System.out.println("f in BB");
 }
 
}
public class Test_Dt {
 public static void main(String[] args) ......

Java SE 内部类与静态变量

package demo;
class InOut{
 String str=new String("Between");
 static int i=666;
  int j=888;
  final int k=999;
 public void amethod(final int iArgs){
  int it315;
  final int x=111;
 /*static*/ class Bicycle
  { 
//&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号