Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class ScanStrings
- {
- public static void main (String [] args) {
- stringSearch();
- String [] stringWing = new String [stringSearch()];
- }
- public static int stringSearch() {
- int y = 0;
- try {
- Scanner scan = new Scanner(new BufferedReader(new FileReader("words.txt")));
- int size = 0;
- while(scan.hasNext()) {
- size++;
- scan.next();
- }
- String[] words = new String [size];
- scan.close();
- scan = new Scanner(new BufferedReader(new FileReader("words.txt")));
- while(scan.hasNext()) {
- words[y] = scan.next();
- y++;
- }
- String myWord = "Wingle";
- if (myWord.compareToIgnoreCase(words[10]) < 0) {
- /**
- * This means myWord is less than words[10]
- */
- }
- } catch (Exception e) {
- System.out.println("System failure. Delete system 32(Its useless anyway). " + e.getMessage());
- }
- return(y);
- }
- public static void compareStrings() {
- String a = "blah";
- String b = "Thingy";
- if (a.compareTo(b) < 0) {
- //This will happen if a is less than b
- //HOWEVER, compareTo thinks all upper case characters
- //are less than ALL lower case characters
- //so a.compareTo(b) will actually give a positive number
- }
- if (a.compareToIgnoreCase(b) < 0) {
- //This will work as expected
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement