txtcopy.java
来自「java网络高级编程的配套源码,java网络高级编程为清华出版社出版.」· Java 代码 · 共 39 行
JAVA
39 行
/*源程序清单7-3*/
class TxtCopy
{
public static void main(String[] args)
{
byte b1=new byte[255];
byte b2=new byte[255];
byte b3=new byte[2056];
byte b4=new byte[2056];
try
{
System.out.println("请输入源文件名称:\n");
System.in.read(b1,0,255);
System.out.println("\n请输入目的文件名称:\n");
System.in.read(b2,0,255);
String sourceName=new String(b1,0);
String desName=new String(b2,0);
FileInputStream fileInput=new FileInputStream(sourceName);
int bytes1=fileInput.read(b3,0,2056);
String sourceFile=new String(b3,0,0,bytes1);
FileOutputStream fileOutput=new FileOutputStream(desName);
FileOutput.write(b3,0,bytes1);
fileInput=new FileInputStream(desName);
int bytes2=fileInput.read(b4,0,2056);
String desFile=new String(b4,0,0,bytes2);
System.out.println("\n源文件内容为:\n");
System.out.println(sourceFile);
System.out.println("\n目的文件内容为:\n);
System.out.println(desFile);
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?