I have an address like: "http://address.com/f1/f2/data.txt"
I'm implementing a Java program that needs to read from the text file, data.txt, preferably line by line, looking for a pattern.
I've searched, what I found and tried was using BufferedReader and Jsoup(I know that using Jsoup doen't make that sense bacause the file is a text file not a html, but I tried it). None of them worked fine and in both I got this error: (No such file or directory)
Here is my code:
public static String getData(String path, String pattern) {
StringBuilder contentBuilder = new StringBuilder();
String str ="";
try {
BufferedReader in = new BufferedReader(new FileReader(path));
while ((str = in.readLine()) != null) {
System.out.println(str);
if (str.equals(pattern))
break;
}
str = in.readLine();
in.close();
} catch (IOException e) {
System.out.println(e.toString());
}
return str;
}
Any clue how to read this file?