-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrieArticles.java
More file actions
36 lines (28 loc) · 840 Bytes
/
TrieArticles.java
File metadata and controls
36 lines (28 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.trie;
import java.util.Scanner;
public class TrieArticles {
//main method
public static void main(String[] args) {
String submittedString=new String();
String line="";
Scanner stdin=new Scanner(System.in);
Trie newTrie = new Trie();
//Input file name from user
System.out.println("Enter the article: ");
while (stdin.hasNextLine() && !(line=stdin.nextLine()).equals(".")){
submittedString+= line;
if(line.length()>2){
String checkPeriod=line.substring(line.length()-2);
if(checkPeriod.equals("..")) {
break;
}
}
}
//TrieArticles ta = new TrieArticles();
newTrie.createCompanyTrie();
System.out.println(submittedString);
String lower=submittedString.toLowerCase();
newTrie.searchArticle(lower);
stdin.close();
}
}