import java.io.*;
import java.util.*;
/**
* @author madis
*
*/
public class htslvl1 {
private static boolean vastavus(String yks, String kaks) {
if (yks.length()==kaks.length()) {
//System.out.println("pikkus sama:"+yks+"="+kaks);
for (char taht1 : yks.toCharArray()) {
if (kaks.indexOf(taht1)<0) return false;
}
for (char taht2 : kaks.toCharArray()) {
if (yks.indexOf(taht2)<0) return false;
}
return true;
}
return false;
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
Vector
Vector
Vector
BufferedReader sisf1; // failimuutuja
try {
sisf1 = new BufferedReader(new FileReader("wordlist.txt")); // avame faili lugemiseks
System.out.println("Avasin faili wordlist.txt lugemiseks.");
String algrida;
while ((algrida=sisf1.readLine())!= null) {
failiread.add(algrida);
System.out.println(algrida);
algrida=null;
}
System.out.println("Kokku lugesin "+failiread.size()+" rida");
sisf1.close();
sisf1 = new BufferedReader(new FileReader("segu.txt")); // avame faili lugemiseks
System.out.println("Avasin faili segu.txt lugemiseks.");
while ((algrida=sisf1.readLine())!= null) {
reatoorik.add(algrida);
algrida=null;
}
System.out.println("Kokku lugesin "+reatoorik.size()+" rida");
sisf1.close();
StringTokenizer rida;
for (String ajurida : reatoorik) {
// System.out.println(segurida);
rida = new StringTokenizer(ajurida);
rida.nextToken();
String temp=rida.nextToken();
seguread.add(temp);
System.out.println(temp);
}
for (String segurida : seguread) {
for (String failirida : failiread) {
if (vastavus(failirida, segurida)) System.out.print(failirida+",");
}
}
}
catch (Exception e) {
if (e instanceof NoSuchElementException) System.out.println("Probleem oli stringi integeriks tegemisega");
else if (e instanceof FileNotFoundException) System.out.println("Ei leitud faili, mida lugeda.");
else if (e instanceof IOException) System.out.println("Tekkis sisend-vljund viga.");
else if (e instanceof NullPointerException) System.out.println("Prooviti thjast stringist numbreid teha.");
}
}
}
Täitsa higiseks võttis! Ammu pole koodinud.
Kommentaare ei ole:
Postita kommentaar