Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
TFJ-546 close streams for sure
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke committed Jan 28, 2011
1 parent 923f602 commit 9d76785
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
31 changes: 21 additions & 10 deletions twitter4j-core/src/main/java/twitter4j/api/GeoMethods.java
Expand Up @@ -26,7 +26,12 @@
*/
package twitter4j.api;

import twitter4j.*;
import twitter4j.GeoLocation;
import twitter4j.GeoQuery;
import twitter4j.Place;
import twitter4j.ResponseList;
import twitter4j.SimilarPlaces;
import twitter4j.TwitterException;

/**
* @author Yusuke Yamamoto - yusuke at mac.com
Expand All @@ -38,6 +43,7 @@ public interface GeoMethods {
* <br>Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location with a call to statuses/update.
* <br>This is the recommended method to use find places that can be attached to statuses/update. Unlike geo/reverse_geocode which provides raw data access, this endpoint can potentially re-order places with regards to the user who is authenticated. This approach is also preferred for interactive place matching with the user.
* <br>This method calls http://api.twitter.com/1/geo/search.json
*
* @param query search query
* @return places (cities and neighborhoods) that can be attached to a statuses/update
* @throws TwitterException when Twitter service or network is unavailable
Expand All @@ -51,10 +57,11 @@ public interface GeoMethods {
* <br>Conceptually you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to post/geo/place to create a new one.
* <br>The token contained in the response is the token needed to be able to create a new place.
* <br>This method calls http://api.twitter.com/1/geo/similar_places.json
* @param location The latitude and longitude to search around.
* @param name The name a place is known as.
*
* @param location The latitude and longitude to search around.
* @param name The name a place is known as.
* @param containedWithin optional: the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
* @param streetAddress optional: This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted. Learn more about Place Attributes.
* @param streetAddress optional: This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted. Learn more about Place Attributes.
* @return places (cities and neighborhoods) that can be attached to a statuses/update
* @throws TwitterException when Twitter service or network is unavailable
* @since Twitter4J 2.1.7
Expand All @@ -64,12 +71,13 @@ public interface GeoMethods {
/**
* Search for places (cities and neighborhoods) that can be attached to a <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0update">statuses/update</a>. Given a latitude and a longitude pair, or an IP address, return a list of all the valid cities and neighborhoods that can be used as a place_id when updating a status. Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location up with a call to <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0update">statuses/update</a>.
* <br>This method calls http://api.twitter.com/1/geo/nearby_places.json
*
* @param query search query
* @return places (cities and neighborhoods) that can be attached to a statuses/update
* @throws TwitterException when Twitter service or network is unavailable
* @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-GET-geo-nearby_places">Twitter API Wiki / Twitter REST API Method: GET geo nearby_places</a>
* @deprecated <a href="http://code.google.com/p/twitter-api/issues/detail?id=1754">Issue 1754</a>
* @since Twitter4J 2.1.1
* @deprecated <a href="http://code.google.com/p/twitter-api/issues/detail?id=1754">Issue 1754</a>
*/
ResponseList<Place> getNearbyPlaces(GeoQuery query) throws TwitterException;

Expand All @@ -78,6 +86,7 @@ public interface GeoMethods {
* There are multiple granularities of places that can be returned -- "neighborhoods", "cities", etc. At this time, only United States data is available through this method.<br>
* This API call is meant to be an informative call and will deliver generalized results about geography.
* <br>This method calls http://api.twitter.com/1/geo/reverse_geocode.json
*
* @param query search query
* @return places (cities and neighborhoods) that can be attached to a statuses/update
* @throws TwitterException when Twitter service or network is unavailable
Expand All @@ -87,8 +96,9 @@ public interface GeoMethods {
ResponseList<Place> reverseGeoCode(GeoQuery query) throws TwitterException;

/**
* Find out more details of a place that was returned from the {@link twitter4j.api.GeoMethodsAsync#reverseGeoCode(twitter4j.GeoQuery)} method.
* Find out more details of a place that was returned from the {@link twitter4j.api.GeoMethods#reverseGeoCode(twitter4j.GeoQuery)} method.
* <br>This method calls http://api.twitter.com/1/geo/id/:id.json
*
* @param id The ID of the location to query about.
* @return details of the specified place
* @throws TwitterException when Twitter service or network is unavailable
Expand All @@ -100,11 +110,12 @@ public interface GeoMethods {
/**
* Creates a new place at the given latitude and longitude.
* <br>This method calls http://api.twitter.com/1/geo/place.json
* @param name The name a place is known as.
*
* @param name The name a place is known as.
* @param containedWithin The place_id within which the new place can be found. Try and be as close as possible with the containing place. For example, for a room in a building, set the contained_within as the building place_id.
* @param token The token found in the response from geo/similar_places.
* @param location The latitude and longitude the place is located at.
* @param streetAddress optional: This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted. Learn more about Place Attributes.
* @param token The token found in the response from geo/similar_places.
* @param location The latitude and longitude the place is located at.
* @param streetAddress optional: This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted. Learn more about Place Attributes.
* @return the created place
* @throws TwitterException when Twitter service or network is unavailable
* @see <a href="http://dev.twitter.com/doc/post/geo/place">POST geo/place | dev.twitter.com</a>
Expand Down
Expand Up @@ -154,7 +154,7 @@ private boolean loadProperties(Properties props, String path) {
File file = new File(path);
if (file.exists() && file.isFile()) {
fis = new FileInputStream(file);
props.load(new FileInputStream(file));
props.load(fis);
normalize(props);
return true;
}
Expand Down
Expand Up @@ -98,7 +98,7 @@ public final InputStream asStream() {
*/
public final String asString() throws TwitterException {
if (null == responseAsString) {
BufferedReader br;
BufferedReader br = null;
InputStream stream = null;
try {
stream = asStream();
Expand Down Expand Up @@ -127,6 +127,12 @@ public final String asString() throws TwitterException {
} catch (IOException ignore) {
}
}
if (null != br) {
try {
br.close();
} catch (IOException ignore) {
}
}
disconnectForcibly();
}
}
Expand Down

0 comments on commit 9d76785

Please sign in to comment.