这一章节的文件拷贝实操总是报错,请老师看看,是需要我先创建文件吗?
package com.program; import java.io.*; public class CopyFileDirectory { public static void main(String[] args) { File src=new File("D:/a/java"); File des=new File("E:/b"); copyDir(src,des); } public static void copyDir(File SrcDir,File TargetDir) { if (TargetDir != null) { TargetDir.mkdir();//如果目的地的目录不存在,那么创建目录 } File[] files = SrcDir.listFiles(); for (File file : files) { if (file.isFile()) { copyFile(new File(SrcDir + "" + file.getName()), new File(TargetDir + "" + file.getName())); } else { copyDir(new File(SrcDir + "" + file.getName()), new File(TargetDir + "" + file.getName())); } } } public static void copyFile(File srcfile, File Desfile ){ BufferedInputStream bis= null; BufferedOutputStream bos=null; try{ bis=new BufferedInputStream(new FileInputStream(srcfile)); bos=new BufferedOutputStream(new FileOutputStream(Desfile)); byte[] by=new byte[1024]; int temp=0; while((temp=bis.read(by))!=-1){ bos.write(temp); } bos.flush(); }catch(Exception e){ e.printStackTrace(); }finally { try{ if (bos!=null){ bos.close(); } if (bis!=null){ bis.close(); } }catch (Exception e){ e.printStackTrace(); } } } }
老师你好,在visual stdio code中用debugger for java插件提供的终端编译,可输出中文,但scanner无法正确读取中文字符串,表现为乱码或者空。修改文件编码方式为GBK也无效。这个问题似乎与终端有关,因为在在powershell中编译相同代码可以正确读入输出中文,IDEA中也无法复现。这是我的测试代码:
import java.util.Scanner; public class inputtest2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s1 = scanner.nextLine(); // 输入"你好"显示乱码,每次不同 String s2 = "你好"; System.out.println(s1); System.out.println(s2); } }
已尝试对字符串进行getBytes()后重新编码(gbk<->utf-8双向都试过),使用new Scanner(System.in, "gbk")指定编码,但都无效。希望咨询老师问题出在什么地方。
老师对这个文件名的保护,能说明一下吗,不太明白的
到这个环节报的错就开始看不懂了, 麻烦老师帮我看一下
parent.zip
有些同学觉得老师讲的不好,我觉得没必要这样说,觉得老师讲的快的可以弄成0.5倍速或者更慢。而且老师讲的快的地方基本都是前面讲过的基础操作,我觉得老师讲的很不错
表格里面使用<thead><tbody><tfoot>是不是为了增强标签的语义性,跟不加这些 显示的效果页面是一样的吗
老师,为什么程序中7%4最后得出来3,如果按照正常的算法7/4=1.75 3是怎么来的
老师,重定向不是地址栏发生改变吗,为什么添加用户成功后没有改变呀?
老师,这是怎么回事,我感觉没有什么问题啊
老师麻烦看看什么原因?我试了好多次。。。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Canvas多个小球随机运动.html</title> <style> canvas{ border: 1px solid #000; } </style> </head> <body> <canvas width="400px" height="300px">您的浏览器不支持canvas,请升级浏览器!</canvas> </body> <script> /*var modul = (function () { function getElement(eleName) { return document.querySelector(eleName); } return { getElement:getElement }; })(); var canvas = modul.getElement("canvas"); var ctx = canvas.getContext("2d"); console.log(canvas);*/ var canvas = document.querySelector("canvas"); var ctx = canvas.getContext("2d"); function randomColor() { var r = parseInt(Math.random() * 256); var g = parseInt(Math.random() * 256); var b = parseInt(Math.random() * 256); var CircleColor = "rgb(" + r + "," + g + "," + b + ")"; return CircleColor; } function Circle() { this.r = Math.floor(Math.random() * 20 + 11); this.x = Math.floor(Math.random() * (400 - this.r)); this.y = Math.floor(Math.random() * (300 - this.r)); this.speedX = Math.floor(Math.random() * 8); this.speedY = Math.floor(Math.random() * 6); this.color = randomColor(); } Circle.prototype.circleSpeed = function () { this.x += this.speedX; if (this.x <= this.r){ this.speedX = -this.speedX; }else if (this.x >= (400 - this.r)){ this.speedX = -this.speedX; } this.y += this.speedY; if (this.y <= this.r){ this.speedY = -this.speedY; }else if (this.y >= (300 - this.r)){ this.speedY = -this.speedY; } }; Circle.prototype.drawCircle = function () { ctx.beginPath(); ctx.arc(this.x,this.y,this.r,0,2*Math.PI); ctx.fillStyle = this.color; ctx.fill(); ctx.closePath(); }; var arr = []; for (var i = 0; i < 4; i++){ arr[i] = new Circle(); } var timer = setInterval(function () { ctx.clearRect(0,0,canvas.width,canvas.height); for (var i = 0; i < arr.length; i++){ arr[i] = circleSpeed(); arr[i] = drawCircle(); } },18); </script> </html>
哪里有问题?
老师这个os.path.join()方法代表的什么意思,能详细说一下吗,只要是提交路径的都用这个方法吗
老师你好 怎么创建文件的时候不是python的文件呀
D:\pycharm\venv\Scripts\python.exe D:/pycharm/GUI/my01.py
File "D:/pycharm/GUI/my01.py", line 3
SyntaxError: Non-UTF-8 code starting with '\xb5' in file D:/pycharm/GUI/my01.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Process finished with exit code 1
老师,这是什么情况啊,我去调了file Encodeing 没用
想请问一下,这个项目是不是得会VUE才适合学,我看这大部分都是前端代码的编写,如果继续往下学这个项目,侧重点应该放在哪块?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637