zoukankan      html  css  js  c++  java
  • 文件上传下载 java阅读


    import java.io.FileInputStream;
    import java.io.FileReader;

    import java.io.FileOutputStream;

    public class Caozuo {
        
        
        //在线阅读
        public  void  yuedu(String lujing) throws Exception{
            FileReader fr=new FileReader(lujing);
            int date;
            while((date=fr.read())!=-1){    
                System.out.print((char)date);
            }
            fr.close();
            System.out.println();
            
        }
        
        //下载
        public void xiazai(Wuxia wx,int index) throws Exception{
            String lujing=wx.list.get(index).getLujing();
            String xiazailj="E:\U1\"+wx.list.get(index).getName()+".txt";
                FileInputStream fis=new FileInputStream(lujing);
                FileOutputStream fos=new FileOutputStream(xiazailj);
                int date;
                byte[] bytes=new byte[1024];
                while((date=fis.read(bytes, 0, bytes.length))!=-1){
                    fos.write(bytes, 0, date);
                }
                fis.close();
               fos.close();
               System.out.println("文件的名字是"+wx.list.get(index).getName());
                System.out.println("文件的下载路径是"+xiazailj);
                
        }
        //上传
        public void shangchuan(Wuxia wx,String daichuan,String name) throws Exception{
            
            String xiazailj="D:\U1\"+name+".txt";
                FileInputStream fis=new FileInputStream(daichuan);
                FileOutputStream fos=new FileOutputStream(xiazailj);
                int date;
                byte[] bytes=new byte[1024];
                while((date=fis.read(bytes, 0, bytes.length))!=-1){
                    fos.write(bytes, 0, date);
                }
                fis.close();
               fos.close();
              
                
        }
        
        
    }

  • 相关阅读:
    “能用”距离“好用”有多远?
    序列化到底是神马?
    新版Microsoft Azure Web管理控制台
    玩转Windows Azure存储服务——高级存储
    Windows 10 Threshold 2 升级记录
    玩转Windows Azure存储服务——网盘
    Windows Azure HDInsight 使用技巧
    Docker on Microsoft Azure
    Azure Linux VM Swap 分区
    Google Cloud Platform
  • 原文地址:https://www.cnblogs.com/anshuo/p/5384678.html
Copyright © 2011-2022 走看看