All pastes #1036990 Raw Edit

Someone

public java v1 · immutable
#1036990 ·published 2008-06-02 16:58 UTC
rendered paste body
import java.io.*;import java.util.*;public class wordCounter {	static List<String> L = new LinkedList<String>(); //Speichert die Wrter (jedes nur einmal)	static int[] a = new int[1000]; //fr die Anzahl der Wiederholung vom wort i	static void blather(File inputFile) throws	IOException{		Scanner sc = new Scanner(inputFile);		sc.useDelimiter("[^a-zA-Z]");		String word;		while(sc.hasNext()){			word = sc.next();			word = word.toLowerCase();			if(!word.equals("")){				if (L.indexOf(word) == -1) //noch nicht in der List					L.add(word);				a[L.indexOf(word)]++;			}		}	}	public static void main(String[] args){		for(int i = 0; i < a.length; i++)			a[i] = 0;		File f = new File("test.txt");		try {			blather(f);		} catch (IOException e) {			System.err.println ("Fehler halt");		}		for(int i = 0; i < L.size(); i++){			int max = 0;			for(int j = 0; j < L.size(); j++){				if(a[max]< a[j]) max = j;			}			Out.print("Anzahl: "+a[max]);  Out.println("    Wort: "+L.get(max));			a[max] = 0;		}	}}