Java Code Examples for java.net.URLConnection#getHeaderFieldInt()

The following examples show how to use java.net.URLConnection#getHeaderFieldInt() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public List<MagicCard> searchCardByCriteria(String att, String crit, MagicEdition me, boolean exact)throws IOException {
	List<MagicCard> lists = new ArrayList<>();
	URLConnection con = null;
	int page = 1;
	String url = getString(JSON_URL) + "/cards?" + att + "=" + URLTools.encode(crit);
	logger.debug(url);

	con = URLTools.openConnection(url);

	int count = 0;
	int totalcount = con.getHeaderFieldInt("Total-Count", 0);

	while (count < totalcount) {
		url = getString(JSON_URL) + "/cards?" + att + "=" + URLTools.encode(crit) + "&page=" + page++;
		logger.trace(url);
		JsonArray jsonList = URLTools.extractJson(url).getAsJsonObject().getAsJsonArray("cards");
		for (int i = 0; i < jsonList.size(); i++) {
			lists.add(loadCard(jsonList.get(i).getAsJsonObject()));
		}
		count += con.getHeaderFieldInt("Count", 0);
	}
	return lists;
}