会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132358个问题
Python 全系列/第一阶段:Python入门/Python入门(动画版) 1488楼
Python 全系列/第十五阶段:Python 爬虫开发/scrapy框架使用(旧) 1489楼
Python 全系列/第一阶段:Python入门/编程基本概念 1490楼
Python 全系列/第五阶段:数据库编程/mysql介绍与环境安装 1492楼
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 1494楼
Python 全系列/第一阶段:Python入门/函数和内存分析 1496楼

java.io.FileNotFoundException: D:\游戏. (拒绝访问。)

at java.base/java.io.FileInputStream.open0(Native Method)

at java.base/java.io.FileInputStream.open(FileInputStream.java:213)

at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)

at sn.sxt.复制.TestCopy.copyFile(TestCopy.java:22)

at sn.sxt.复制.TestCopy.main(TestCopy.java:14)




这是代码

package sn.sxt.复制;


import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;


public class TestCopy {

public static void main(String[] args) throws IOException {

File srcFile=new File("D:\\游戏.");

File targeFile =new File("D:\\游戏.");

copyFile(srcFile, targeFile);

}

public static void copyFile(File srcFile,File targeFile) throws IOException {

//(1)提高读取效率,从数据源             字节输入流

BufferedInputStream bis = null;

//(2)提高写入效率,写到目的地              字节输出流

BufferedOutputStream bos = null;

try {

bis = new BufferedInputStream(new FileInputStream(srcFile));

bos = new BufferedOutputStream(new FileOutputStream(targeFile));

  

//(3)边读边写

byte[] buf=new byte[1024];   //数组当中中转站

int len=0;             //用于储存数

while((len=bis.read(buf))!=0) {    //把输入的数据存到buf数组中,赋值到len中 。当不等于0时(没有数据)停止

bos.write(buf,0,len);    //添加到bos中 (缓存到buf数组中,从0开始,到循环结束)

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}finally { 

//(5)关闭

try {

if(bos!=null) {

   bos.close();

}if(bis!=null) {

bis.close();

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}


}


JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 1497楼

import java.util.Scanner;
public class salaryCalculator {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("**********我的薪水计算器********");
        System.out.println("1、输入88.退出程序。 \n2、输入66,计算下一个年薪");
        while(true){
            System.out.println("请输入你的月薪");
            int monthSalary = s.nextInt();
            System.out.println("每年是几个月的薪水");
            int months = s.nextInt();
            int yearSalary = monthSalary*months;
            System.out.println("你的年薪是"+yearSalary);
            if (yearSalary>200000){
                System.out.println("恭喜你超越98%的人,大佬");
            }
                else if (yearSalary>100000){
                    System.out.println("恭喜你超越90%的人");
                }
            }

            System.out.println("输入88,退出系统;输入66,进行下一个用户");
            int comm = s.nextInt();
            if (comm == 88){
                System.out.println("退出系统!");
                break;
            }
            if (comm == 66){
                System.out.println("继续计算下一个用户");
                continue;
            }


        }

    }

同样代码,我出了这个问题

image.png

JAVA 全系列/第一阶段:JAVA 快速入门/控制语句、方法、递归算法 1498楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637