我做了一个下载··
想在下载过程中下载进度在进度条里面显示
我没有实现
现在是在另外一个类里面
我应该怎么做···
谢谢···
不要从忘上的代码··
我都找过了··
没有能用的··
谢谢·····

解决方案 »

  1.   

    我想的是先获得文件的大小,然后在获得文件在下载过程中的大小··让他们量个进行比较····然后用线程去改写进度条的值
    可是我获得不了ftp上文件的大小···code:
    public static boolean downLoadFtp(String ftpServerIp,String ftpUser,String ftpPassWord,String url,String filePath,String fileName){ 
    try 
            { 
                FtpClient fc=new FtpClient(ftpServerIp); 
                fc.login(ftpUser,ftpPassWord); 
                fc.binary(); 
                int ch; 
                int filesize=0; 
                String fileStr = filePath + fileName; 
    System.out.println(fileStr); 
    File filename = new File(fileStr); if(filename.exists()){ 
    return false; 

    if (!filename.exists()) { 
    if (filename.createNewFile()) { 
    System.out.println("File  is  created  successfully!"); 


                RandomAccessFile getFile = new RandomAccessFile(fileStr,"rw"); 
              
                getFile.seek(0); 
                //url="/FTPTest1.txt"; 
                TelnetInputStream fget=fc.get(fileName);             DataInputStream puts = new DataInputStream(fget); 
                while ((ch = puts.read()) >= 0) { 
                filesize  =filesize+ch;            
              
                    getFile.write(ch); 
                }             fget.close(); 
                getFile.close(); 
                fc.closeServer(); 
            } 
            catch (IOException ex) 
            { 
    System.out.println("C::  download  89    FTP ERROR!!");          
    ex.printStackTrace(); 
            
            } 
            return true; 

    请指教···谢谢·····