我有一个可以读取CSV文件的类,但是当文件大时,程序会引发public class Mapsactivity extends Fragmentactivity implements OnmapReadyCallback {
private GoogleMap mMap;
public Location myLocation;
public LatLng currentLocation;
public double latitude;
public double longitude;
FusedLocationProviderClient fusedLocationProviderClient;
private static final int REQUEST_CODE = 101;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
currentLocation = new LatLng(0,0);
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
}
private void getcurrentLocation() {
if (activityCompat.checkSelfPermission(this,android.Manifest.permission.accESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && activityCompat.checkSelfPermission(this,android.Manifest.permission.accESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
activityCompat.requestPermissions(this,new String[]{Manifest.permission.accESS_FINE_LOCATION},REQUEST_CODE);
return;
}
Task<Location> task = fusedLocationProviderClient.getLastLocation();
task.addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if(location != null){
myLocation = location;
double lat = location.getLatitude();
double lon = location.getLongitude();
Log.v("Mapsactivity","Lat: " + latitude + " Long: " + longitude);
latitude = lat;
longitude = lon;
LatLng current = new LatLng(latitude,longitude);
currentLocation = current;
}
}
});
}
@Override
public void onmapReady(GoogleMap googleMap) {
if (activityCompat.checkSelfPermission(this,REQUEST_CODE);
return;
}
getcurrentLocation();
Log.v("Mapsactivity","Latitude: " + latitude + " Longitude: " + longitude);
mMap = googleMap;
mMap.addMarker(new MarkerOptions().position(currentLocation).title("Your location"));
mMap.animateCamera(CameraUpdateFactory.newLatLngzoom(currentLocation,10));
}
@Override
public void onRequestPermissionsResult(int requestCode,@NonNull String[] permissions,@NonNull int[] grantResults) {
...
}
}
错误,因此我需要将该文件拆分为多个部分,然后根据行大小将行转移到其他文件中。
例如; 我有一个500 000行的文件,我将其划分为5个文件乘以100 000行。因此,我有5个文件,由10万行组成,以便我阅读它们。
我找不到方法,所以如果我看到示例代码行,那就太好了。