doha786 0 Light Poster

i have code to find next string after a particular string that shows result correctly..

right now i want to make an array to show the list of my output's name.

FileReader fr;	BufferedReader br;
String result="";
String word= new String();
String target = "friend";


try{ //read large text file 
fr = new FileReader ("C:/Users/user/Desktop/java/test.txt");
br = new BufferedReader(fr);
Scanner scan = new Scanner(br);

while(scan.hasNext()){  
result = scan.findWithinHorizon(target,0); 

if(result!=null) {
word = (scan.next() + scan.findWithinHorizon("", 0));

System.out.println(word);

output is :
rocky
jamila
vicky
jacky
adam
david