我建议使用StringBuilder。
从这里http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/location/Location.java#Location.toString%28%29:
@Override public String [More ...] toString() {
return "Location[mProvider=" + mProvider +
",mTime=" + mTime +
",mLatitude=" + mLatitude +
",mLongitude=" + mLongitude +
",mHasAltitude=" + mHasAltitude +
",mAltitude=" + mAltitude +
",mHasSpeed=" + mHasSpeed +
",mSpeed=" + mSpeed +
",mHasBearing=" + mHasBearing +
",mBearing=" + mBearing +
",mHasAccuracy=" + mHasAccuracy +
",mAccuracy=" + mAccuracy +
",mExtras=" + mExtras + "]";
}
我建议您自己按照以下方式编写:
public static List<Location> GPSLocalLocations = new ArrayList<Location>(1);
StringBuilder gpslog = new StringBuilder();
for (int i=0; i<GPSService.GPSLocalLocations.size(); i++)
{
Location location = GPSService.GPSLocalLocations.get(i);
gpslog.append("\n")
.append("Location[Provider=").append(location.getProvider(())())
.append(",Time=").append(location.getTime())
.append(",Latitude=").append(location.getLatitude())
.append(",Longitude=").append(location.getLongitude())
.append(",HasAltitude=").append(location.getHasAltitude())
.append(",Altitude=").append(location.getAltitude())
.append(",HasSpeed=").append(location.getHasSpeed())
.append(",Speed=").append(location.getSpeed())
.append(",HasBearing=").append(location.getHasBearing())
.append(",Bearing=").append(location.getBearing())
.append(",HasAccuracy=").append(location.getHasAccuracy())
.append(",Accuracy=").append(location.getAccuracy())
.append(",Extras=").append(location.getExtras()).append("]");
}