Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Connection {
- ArrayList<String> StringArray = new ArrayList<String>();
- private String fileExtension = "jpg";
- private String html = "http://mcs.une.edu.au/~salmutai/cameras";
- private int count = 0;
- public void UrlExtract() throws Exception {
- Document doc = Jsoup.connect(html).get();
- Elements castURL = doc.select("a");
- for (Element el : castURL) {
- String src = el.absUrl("href");
- String extension = src.substring(src.lastIndexOf(".") + 1,
- src.length());
- if (extension.equalsIgnoreCase(fileExtension)) {
- StringArray.add(src);
- count++;
- }
- }
- }
- public int getCount() throws Exception {
- return count;
- }
- public String ImgArray(int i) throws Exception {
- String[] StrArray = new String[count];
- StrArray = (String[]) StringArray.toArray(StrArray);
- return StrArray[i];
- }
- String text = "Found " + StringArray.size() + " images at the url: " + html;
- Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
- try {
- Connection co = new Connection();
- co.UrlExtract();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement