Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.144.21.206
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/zan/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/zan/Compare.java
import java.util.Scanner;
import java.io.File;


public class Compare
{
    public static void main(String[] args)  throws java.io.FileNotFoundException
    {
        boolean same=true;

                if (args.length < 2)
                {
                    System.out.println("Need two files!");
                    System.exit(0);

                }


        Scanner file1 = new Scanner(new File(args[0]));
        Scanner file2 = new Scanner(new File(args[1]));




            if ((file1.hasNext())  && !(file2.hasNext()) )
                same = false;
            if ((file2.hasNext())  && !(file1.hasNext()) )
                same = false;
        while (((file1.hasNext()) || (file2.hasNext())) && (same) )
        {
            String text1 = file1.nextLine();
            String text2 = file2.nextLine();

            if (text1.equals(text2))
                same = true;
            else
                same = false;
        }

        System.out.println("Are the files the same? " + same);



    }
}

Stv3n404 - 2023