Reputation:
I'm trying to implement a URL connection that has a list of words my program reads, but currently can't find a solution. My code at the moment reads from a .txt file but I need it to read a list from a URL
I've tried:
URL url = new URL("my url ");
URLConnection con = url.openConnection();
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
System.out.println(body);
public static List<String> readFileInList(String myFileName)
{
List<String> lines = Collections.emptyList();
try
{
lines =
Files.readAllLines(Paths.get(fileName), StandardCharsets.UTF_8);
}
catch (IOException e)
{
e.printStackTrace();
}
return lines;
}
public static void main(String[] args) throws FileNotFoundException
List l = readFileInList("my file");
char board[][] = {
{'X','A','G','L','K'},
{'Y','U','P','T','K'},
{'Z','Y','N','X','M'},
{'Q','G','E','E','B'},
{'R','O','A','P','Q'}};
System.out.println("");
Search(board);
Upvotes: 0
Views: 103
Reputation: 25
My small web scraping app for you: web scraping app
The app get data from URL
Upvotes: 0