java 编写程序,拷贝一个带内容的文件夹。 例如:将c:\program files\java 文件夹拷贝到D盘的根目录下
答案:1 悬赏:70 手机版
解决时间 2021-03-09 04:31
- 提问者网友:浪荡绅士
- 2021-03-08 23:21
java 编写程序,拷贝一个带内容的文件夹。 例如:将c:\program files\java 文件夹拷贝到D盘的根目录下
最佳答案
- 五星知识达人网友:神的生死簿
- 2021-03-09 00:54
一、复制文件代码
print?import java.io.*;
import java.util.*;
class Copy
{
static void copy(String from,String to) throws IOException
{
BufferedReader in=new BufferedReader(new FileReader(from));
BufferedWriter out=new BufferedWriter(new FileWriter(new File(to)));
String line=null;
while((line=in.readLine())!=null)
{
out.write(line+"\n");
}
in.close();
out.close();
}
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
System.out.print("请输入文件路径:");
String from=sc.next();
System.out.print("请输入拷贝路径:");
String to=sc.next();
copy(from,to);
}
}
import java.io.*;
import java.util.*;
class Copy
{
static void copy(String from,String to) throws IOException
{
BufferedReader in=new BufferedReader(new FileReader(from));
BufferedWriter out=new BufferedWriter(new FileWriter(new File(to)));
String line=null;
while((line=in.readLine())!=null)
{
out.write(line+"\n");
}
in.close();
out.close();
}
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
System.out.print("请输入文件路径:");
String from=sc.next();
System.out.print("请输入拷贝路径:");
String to=sc.next();
copy(from,to);
}
}
二、复制文件夹代码 https://wenku.baidu.com/view/2fedc744f7ec4afe04a1df37.html
print?import java.io.*;
import java.util.*;
class Copy
{
static void copy(String from,String to) throws IOException
{
BufferedReader in=new BufferedReader(new FileReader(from));
BufferedWriter out=new BufferedWriter(new FileWriter(new File(to)));
String line=null;
while((line=in.readLine())!=null)
{
out.write(line+"\n");
}
in.close();
out.close();
}
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
System.out.print("请输入文件路径:");
String from=sc.next();
System.out.print("请输入拷贝路径:");
String to=sc.next();
copy(from,to);
}
}
import java.io.*;
import java.util.*;
class Copy
{
static void copy(String from,String to) throws IOException
{
BufferedReader in=new BufferedReader(new FileReader(from));
BufferedWriter out=new BufferedWriter(new FileWriter(new File(to)));
String line=null;
while((line=in.readLine())!=null)
{
out.write(line+"\n");
}
in.close();
out.close();
}
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
System.out.print("请输入文件路径:");
String from=sc.next();
System.out.print("请输入拷贝路径:");
String to=sc.next();
copy(from,to);
}
}
二、复制文件夹代码 https://wenku.baidu.com/view/2fedc744f7ec4afe04a1df37.html
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯