I am trying to extract a data from a raw text file in my raw directory by reading it and getting the string after the colon preceded by a category and storing it in a class variable. The raw text file is as follows:
category:AI
photo:ai4.png
title:'I will destroy humans': Humanoid AI robot Sophia gets Saudi citizenship
website:https://www.deccanchronicle.com/lifestyle/viral-and-trending/111117/i-will-destroy-humans-humanoid-ai-robot-sophia-gets-saudi-citizenship.html
date:11-11-2017
category:cybersecurity
photo:cyber3.png
title:WhatsApp and Telegram media files aren't so secure
website:https://www.theverge.com/2019/7/15/20692184/whatsapp-telegram-media-files-android-messaging-encryption
date:15-07-2019
I want to be able to read the first line and check what category it is, if the category is photo, I want to store the ai4.png in the class variable related to it. After it reaches date and the date data is stored in the date class variable. It will instantiate a new class and begin the process again with a new class.
The class is as follows:
public class Link{
private String title;
private String imageName;
private String url;
Link(String t,String i,String u){
this.title=t;
this.imageName=i;
this.url=u;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getImageName() {
return imageName;
}
public void setImageName(String imageName) {
this.imageName = imageName;
}
public String getURL(){
return url;
}
public void setURL(String url){
this.url = url;
}
}
So by reading the text file, if it is title preceded by colon, it will assign the title text after the colon to the title class variable.
Sorry, I am new to android and Java in general, any help is appreciated. Thanks for reading!