有人能帮我把下面的代码每行都加双斜杠注释是什么意思!(前几行都注了,就那样)
packagecom.shanben.io;importjava.io.File;//导包importjava.io.FileInputStream;importjava...
package com.shanben.io;
import java.io.File;//导包
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class FileUtil {
private void copy(String path){ //复制功能要求传入一个文件路径
System.out.print("请输入您要复制到的路径:");//输出提示
Scanner sc = new Scanner(System.in);//构造对象
String path1=sc.next();
File f = new File(path);
File f1 = new File(path1);
if(!f1.exists()){
f1.mkdirs();
}
f1 = new File(path1+"\\"+f.getName());
try {
f1.createNewFile();
FileInputStream fis = new FileInputStream(f);
FileOutputStream fos = new FileOutputStream(f1);
int i;
while((i=fis.read())!=-1){
fos.write(i);
}
fos.close();
fis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void open(String path){
File ff = new File(path);
File[] sa = ff.listFiles();
for(int i=0;i<sa.length;i++){
System.out.println(i+"\t"+sa[i].getName());
}
System.out.println("请选择一个文件:");
Scanner sc = new Scanner(System.in);
int se = sc.nextInt();
System.out.println("1.打开");
System.out.println("2.删除");
System.out.println("3.复制");
System.out.println("4.查看详情");
System.out.println("0.返回");
int ss = sc.nextInt();
switch(ss){
case 1:
open(sa[se].getAbsolutePath());
break;
case 2:
sa[se].delete();
break;
case 3:
copy(sa[se].getAbsolutePath());
break;
case 4:
System.out.println("是否是文件:"+ff.isFile());
System.out.println("是否是目录:"+ff.isDirectory());
System.out.println("绝对路径:"+ff.getAbsolutePath());
System.out.println("文件大小:"+ff.length());
}
}
}
我知道我代码有点长——,我学软件的,这几天感冒,上课没听懂,好多东西没会,求好心人帮个忙!!!! 展开
import java.io.File;//导包
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class FileUtil {
private void copy(String path){ //复制功能要求传入一个文件路径
System.out.print("请输入您要复制到的路径:");//输出提示
Scanner sc = new Scanner(System.in);//构造对象
String path1=sc.next();
File f = new File(path);
File f1 = new File(path1);
if(!f1.exists()){
f1.mkdirs();
}
f1 = new File(path1+"\\"+f.getName());
try {
f1.createNewFile();
FileInputStream fis = new FileInputStream(f);
FileOutputStream fos = new FileOutputStream(f1);
int i;
while((i=fis.read())!=-1){
fos.write(i);
}
fos.close();
fis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void open(String path){
File ff = new File(path);
File[] sa = ff.listFiles();
for(int i=0;i<sa.length;i++){
System.out.println(i+"\t"+sa[i].getName());
}
System.out.println("请选择一个文件:");
Scanner sc = new Scanner(System.in);
int se = sc.nextInt();
System.out.println("1.打开");
System.out.println("2.删除");
System.out.println("3.复制");
System.out.println("4.查看详情");
System.out.println("0.返回");
int ss = sc.nextInt();
switch(ss){
case 1:
open(sa[se].getAbsolutePath());
break;
case 2:
sa[se].delete();
break;
case 3:
copy(sa[se].getAbsolutePath());
break;
case 4:
System.out.println("是否是文件:"+ff.isFile());
System.out.println("是否是目录:"+ff.isDirectory());
System.out.println("绝对路径:"+ff.getAbsolutePath());
System.out.println("文件大小:"+ff.length());
}
}
}
我知道我代码有点长——,我学软件的,这几天感冒,上课没听懂,好多东西没会,求好心人帮个忙!!!! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询