Archive for June, 2010

03
Jun
10

how to find the content-length of a URL using URLConnection/HttpUrlConnection


Here’s how:


URLConnection a = new URL("http://insertWebsiteAddressHere").openConnection();
System.out.println(a.getContentLength());

Advertisements
03
Jun
10

find the number of columns in a ResultSet


Suppose you have a ResultSet and you want to find out how many columns it holds. Here’s how you do it:


ResultSet rs = statement.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
int numberOfColumns = metaData.getColumnCount();




Blog Stats

  • 226,721 hits