I have been trying to read data for hackerrank questions, however, although I have tried the following methods, none of them worked properly as explained below. The input file format is like that:
5
2 6 8 9 13
1. Normally I read values with the same format from a local txt file. But when using a local txt file, the code does not work as expected. So, I try to read url with the same method, it does not work as well:
String url= "https://hr-testcases-us-east-1.s3.amazonaws.com/1234/input.txt";
Scanner scan = new Scanner(new File(url)); //I can read from local txt file by using this
Scanner scan = new Scanner(new URL(url).openStream()); //it does not work as well
2. I tried to enter inputs via keyboard, but this also does not work when testing the code in hackerrank.
So, as far as I see, there is a remote txt file and I need to read inputs via Scanner (at least I prefer to use Scanner).
How can I read the values from this remote url?