Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.149.232.87
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 (0755) :  /home/amjamgochian/cs440/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/amjamgochian/cs440/cmp.java
//
//	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]
		boolean done = false;
                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;
			
			while(input1.hasNextLine())
			{
				if(!input2.hasNextLine() && !done)
				{	System.out.println("Not identical.\n\n");
					done = true;
				}
				else
				{	while(input2.hasNextLine() && !done)
					{	text1 = input1.nextLine();
                        			text2 = input2.nextLine();
						if(!text1.equals(text2))
						{	done = true;
							System.out.println("Not identical.\n\n");
						}
					}
				}
				//if(!done)
			}                        

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

Stv3n404 - 2023