Sebastian Zaba

Greenhorn
+ Follow
since Nov 30, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sebastian Zaba

Why would you stay away from whizlabs? Looking to get the OCAJ and looking for resources and Whizlabs seems to have a good reputation.
11 years ago
Anyone has seen this Error: Error validating location: "Could not Connect to :pserver:usr@ip:port /var/lib/csv: Socket Exception: Connection reset"
and the port is Listening
my csvpserver:

service cvspserver
{
port = 2401
socket_type = stream
protocol = tcp
user = root
wait = no
type = UNLISTED
server = /var/lib/cvs
server_args = -f --allow-root /var/lib/cvs pserver
disable = no
}
11 years ago
OK I think i got it. But now:

Its not able to find the hard coded dictionary file how do i enter it so android can find it after installing the apk?

Scanner s = new Scanner(new File("dictionary.txt"));

I am having trouble using getResources() if it is the correct one to use.
11 years ago
First I wanted to thank all the devoted programmers to this site it has been a large help to me. Now lets post something :) I spend 2 days on this now and its driving me crazy I am new to Android development and only somewhat comfortable with JAVA itself. Here is my problem I am writing a quick Android app to take a String permute it and check it against a dictionary but the onClick will only invoke and display the permute and not any of my other functions I tested the functions on a separate Java only tester class and the methods work just fine. here is the relevant Code:


public class HackaWordActivity extends Activity implements OnClickListener {
TextView enterLetters;
TextView possibleWords;
Button button1;
String inputString;
char[] chars;
ListView listView;

static ArrayAdapter<String> adapter; //to fill matches and display


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);

enterLetters = (TextView) this.findViewById(R.id.enterLetters);
listView = (ListView) findViewById(R.id.mylist);

button1 = (Button) this.findViewById(R.id.button1);
button1.setOnClickListener(this);
}
//get user input
public String getString() {

inputString = (enterLetters.getText().toString());
return inputString;

}


@Override
public void onClick(View v) {


// adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1,Permutation.permute("", getString())); //this works and displays the results in the desired listView.

try {
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1,Permutation.compared(getString()));
//this does not work
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
listView.setAdapter(adapter);
}
}

The Permutation Class:

//Permutation is a separate class with contains the methods to be implemented in HackaWordActivity
public class Permutation {


static ArrayList<String> wordArray = new ArrayList<String>();
public static String word;
public static String dictionaryCheck; //temporary holding place for dictionary words to compare
public static ArrayList<String> matches = new ArrayList<String>();

//recursive method that permutes chars in a given String. It takes a blank string, and a String
//It returns an ArrayList with the permuted chars as Strings
public static ArrayList<String> permute(String beginningString, String endingString) {

if (endingString.length() <= 1) {

word = (beginningString + endingString);
wordArray.add(word);
}

else
for (int i = 0; i < endingString.length(); i++) {
try {
String newString = endingString.substring(0, i) + endingString.substring(i + 1);
permute(beginningString + endingString.charAt(i), newString);
} catch (StringIndexOutOfBoundsException exception) {
exception.printStackTrace();
}

}
return wordArray;

}

//Method to check if permuted Strings match words in a hard coded dictionary
public static ArrayList<String> checkDictionary (ArrayList<String> permutedArrayList) throws FileNotFoundException{


Scanner s = new Scanner(new File("dictionary1.txt")); //Creates scanner and reads file that must be in the Project folder
while (s.hasNext()){ //scan the document and set each word as String dictionaryCheck

dictionaryCheck = s.next();

//check the provided arrayList to the dictionary Word saved in dictionaryCheck
for (int word = 0; word<permutedArrayList.size(); word++){
if (permutedArrayList.get(word).equals(dictionaryCheck)){
matches.add(permutedArrayList.get(word));
}
}
}

return matches;

}
//method that simplifies use my combining permuting and matching
public static ArrayList<String> compared (String input)throws FileNotFoundException{

checkDictionary(permute("",input));

return matches;


}
11 years ago