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();
              
                
        }
        
        
    }

  • 相关阅读:
    序列化实现 深拷贝
    为边框应用图片 border-image
    阴影 box-shadow(二)
    阴影 box-shadow(一)
    css3之圆角效果 border-radius
    文档对象模型(DOM)
    Cookie/Session机制详解
    PHP错误The server encountered an internal error or misconfiguration and was unable to complete your re
    关于js with语句的一些理解
    使用JavaScript+Html创建win8应用(二)
  • 原文地址:https://www.cnblogs.com/anshuo/p/5384678.html
Copyright © 2011-2022 走看看