java如何实现文件的复制粘贴?
发布网友
发布时间:2022-04-24 05:52
我来回答
共3个回答
热心网友
时间:2023-10-03 08:06
打开D盘,点编辑,全部选定,右键点变篮的文件选复制,打开E盘右键点空白处选粘贴。
热心网友
时间:2023-10-03 08:07
package cn.yxbsz.InAndOutStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class InAndOutStream {
/**
* @param args
*/
public void InAndOut()
{
try {
OutputStream outstream = null;
String s = "D:"+"\\"+"test.txt";
File file = new File(s);
System.out.println(s);
outstream = new FileOutputStream(file,true);
DataOutputStream dataoutstream = new DataOutputStream(outstream);
DataOutputStream dataoutstream1 = new DataOutputStream(System.out);
try {
dataoutstream.write("你好啊:\r\n".getBytes());
dataoutstream.write("你也好!\r\n".getBytes());
dataoutstream.write("今天天气不错。\r\n".getBytes());
dataoutstream.write("吃饭了吗?\r\n".getBytes());
dataoutstream.flush();
dataoutstream1.write("你好啊:\r\n".getBytes());
dataoutstream1.write("你也好!\r\n".getBytes());
dataoutstream1.write("今天天气不错。\r\n".getBytes());
dataoutstream1.write("吃饭了吗?\r\n".getBytes());
dataoutstream1.flush();
outstream.flush();
System.out.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new InAndOutStream().InAndOut();
}
}
Java,输入输出流使用示例,看不懂在追加提问好了。
热心网友
时间:2023-10-03 08:07
在目标目录中创建和源目录文件相同的文件后,读取源文件内容字节流写入目标文件中。
热心网友
时间:2023-10-03 08:06
打开D盘,点编辑,全部选定,右键点变篮的文件选复制,打开E盘右键点空白处选粘贴。
热心网友
时间:2023-10-03 08:07
package cn.yxbsz.InAndOutStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class InAndOutStream {
/**
* @param args
*/
public void InAndOut()
{
try {
OutputStream outstream = null;
String s = "D:"+"\\"+"test.txt";
File file = new File(s);
System.out.println(s);
outstream = new FileOutputStream(file,true);
DataOutputStream dataoutstream = new DataOutputStream(outstream);
DataOutputStream dataoutstream1 = new DataOutputStream(System.out);
try {
dataoutstream.write("你好啊:\r\n".getBytes());
dataoutstream.write("你也好!\r\n".getBytes());
dataoutstream.write("今天天气不错。\r\n".getBytes());
dataoutstream.write("吃饭了吗?\r\n".getBytes());
dataoutstream.flush();
dataoutstream1.write("你好啊:\r\n".getBytes());
dataoutstream1.write("你也好!\r\n".getBytes());
dataoutstream1.write("今天天气不错。\r\n".getBytes());
dataoutstream1.write("吃饭了吗?\r\n".getBytes());
dataoutstream1.flush();
outstream.flush();
System.out.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new InAndOutStream().InAndOut();
}
}
Java,输入输出流使用示例,看不懂在追加提问好了。
热心网友
时间:2023-10-03 08:07
在目标目录中创建和源目录文件相同的文件后,读取源文件内容字节流写入目标文件中。