Java课程设计 比较两个文件内容是否相同

运行前提:保存三个文本文件“text1.txt”、“text2.txt”、“text3.txt”到存放“IOOperation.java”的同一个文件夹中。其中两个文本文件内容相同,一个不同于其他两个。

运行方法:在命令行提示符模式下cd到“IOOperation.java”所在文件夹,编译命令“javac IOOperation.java”,编译成功后输入“java IOOperation text1.txt text2.txt”就好了。更详细的信息可以看代码。

// Filename: IOOperation.java
import java.io.*;

class  IOOperation
{
	public static void main(String[] args) 
	{
		FileInputStream File1 = null;
		FileInputStream File2 = null;
		BufferedReader in = null;
		String sFile;

		if(args.length != 2)
		{
			System.out.println("The command line should be: java IOOperation testX.txt testX.txt");
			System.out.println("X should be one of the array: 1, 2, 3");
			System.exit(0);
		}

		try
		{
			File1 = new FileInputStream(args[0]);
			File2 = new FileInputStream(args[1]);
			
			//输出两个文件
			try
			{
				//输出文件1
				in = new BufferedReader(new FileReader(args[0]));
				System.ou
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值