Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Random;
- public class Client {
- static String txt = "";
- private static ArrayList<String> status = new ArrayList<String>();
- @SuppressWarnings("static-access")
- public static void main(String []args) throws IOException{
- Algorithms algo = new Algorithms();
- //create();
- ArrayList<String> x = algo.readFile("Category.txt");
- //p(x);
- ArrayList<ArrayList<String>> categories = (Algorithms.breakFile(x));
- //p("Coolness: " + (temp / 1.50) + "%");
- txt = readFiles("markstatus.txt");
- sort(txt);
- status.remove(status.size() - 1);
- // for (int i = 0; i < status.size(); i++){
- // System.out.println(status.get(i));
- // }
- // System.out.println(status.size());
- String name = findName(txt);
- Person person = new Person(name, status);
- ArrayList<String> words = (algo.breakDown(person));
- person.setStatus(words);
- //person.getStatus().add("\"Death\"");
- //person.getStatus().add("\"Achieve\"");
- categories = Algorithms.removeQuotesAndToLowerCase(categories);
- person = Algorithms.toLowerCase(person);
- System.out.println(person.getStatus());
- //person = Algorithms.algorithms(person, categories);
- }
- public ArrayList<String> getStatus(){
- return status;
- }
- public static String findName(String txt){
- int temp = txt.indexOf("\"name\": ");
- int l = "\"name\": ".length();
- String name = txt.substring(temp + l, temp + 100);
- temp = name.substring(1).indexOf("\"");
- temp += 1;
- name = name.substring(1, temp);
- return name;
- }
- public static void create(){
- Random r = new Random();
- p("Name: Shreyas Kalyan ");
- for (int i = 0; i < 200; i++){
- p(Math.abs(r.nextInt()));
- p("Likes: " + r.nextInt(200) + " ");
- }
- }
- public static void p(Object o){
- System.out.println(o);
- }
- static int currindex = 0;
- public static String readFiles(String fName) throws IOException{
- String stuff = " ";
- File file = new File(fName);
- FileReader fr = new FileReader(file);
- String a = new String();
- @SuppressWarnings("resource")
- BufferedReader read = new BufferedReader(fr);
- while ((a = read.readLine()) != null){
- stuff += a;
- }
- return stuff;
- }
- public static void sort(String txt){
- int indexOfmessage = 0;
- int indexOfquote1 = 0;
- int indexOfquote2 = 0;
- while (indexOfmessage != 7){
- indexOfmessage = txt.indexOf("message\"", currindex + 1) + 8;
- indexOfquote1 = txt.indexOf("\"", indexOfmessage + 1) + 1;
- indexOfquote2 = txt.indexOf("\"", indexOfquote1 + 1);
- status.add(txt.substring(indexOfquote1, indexOfquote2));
- currindex = indexOfquote2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement