monchyrcg
11/06/12, 15:16:19
Os pongo el código:
private void leerPuntosApp(){
InputStream stream =getResources().openRawResource(R.raw.sitios);
BufferedReader brin = new BufferedReader(new InputStreamReader(stream));
try {
while(brin.ready()){
String []todoPartes = brin.readLine().split("\n");
for(int i= 0;i<todoPartes.length;i++)
dibujarPuntos(todoPartes[i]);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void leerPuntoPropios(){
String todo = null;
if(sitios.exists() && sitios.canRead()){
FileInputStream fileIN = null;
try{
fileIN = new FileInputStream(sitios);
byte [] reader = new byte[fileIN.available()];
while(fileIN.read(reader)!= -1){ }
todo = new String(reader);
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(fileIN != null){
try{
fileIN.close();
}catch(IOException ioExcep){
ioExcep.printStackTrace();
}
}
}
}
String []todoPartes = todo.split("\n");
for(int i= 0;i<todoPartes.length;i++)
dibujarPuntos(todoPartes[i]);
}
private void dibujarPuntos(String punto){
String []separados = punto.split(",");
Dialog dialog = hacerDialogo(separados[0],separados[1],
separados[2],separados[3],separados[4]);
//AQUI ME DA UN NumberFormatException
lat = Double.parseDouble(separados[0])*1E6;
lon = Double.parseDouble(separados[1])*1E6;
}
El código es bastante sencillo cojo un txt y lo voy partiendo en trozos hasta quedarme con lo que yo quiero. Como veis tengo dos maneras de leer el txt según lo lea de la propia aplicación o de la SD. Cuando leo el txt de la SD no hay problema pero si lo leo de la propia aplicación (carpeta raw) me salta el error y no lo entiendo, los dos los he escrito yo.
Alguien me ayuda?
private void leerPuntosApp(){
InputStream stream =getResources().openRawResource(R.raw.sitios);
BufferedReader brin = new BufferedReader(new InputStreamReader(stream));
try {
while(brin.ready()){
String []todoPartes = brin.readLine().split("\n");
for(int i= 0;i<todoPartes.length;i++)
dibujarPuntos(todoPartes[i]);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void leerPuntoPropios(){
String todo = null;
if(sitios.exists() && sitios.canRead()){
FileInputStream fileIN = null;
try{
fileIN = new FileInputStream(sitios);
byte [] reader = new byte[fileIN.available()];
while(fileIN.read(reader)!= -1){ }
todo = new String(reader);
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(fileIN != null){
try{
fileIN.close();
}catch(IOException ioExcep){
ioExcep.printStackTrace();
}
}
}
}
String []todoPartes = todo.split("\n");
for(int i= 0;i<todoPartes.length;i++)
dibujarPuntos(todoPartes[i]);
}
private void dibujarPuntos(String punto){
String []separados = punto.split(",");
Dialog dialog = hacerDialogo(separados[0],separados[1],
separados[2],separados[3],separados[4]);
//AQUI ME DA UN NumberFormatException
lat = Double.parseDouble(separados[0])*1E6;
lon = Double.parseDouble(separados[1])*1E6;
}
El código es bastante sencillo cojo un txt y lo voy partiendo en trozos hasta quedarme con lo que yo quiero. Como veis tengo dos maneras de leer el txt según lo lea de la propia aplicación o de la SD. Cuando leo el txt de la SD no hay problema pero si lo leo de la propia aplicación (carpeta raw) me salta el error y no lo entiendo, los dos los he escrito yo.
Alguien me ayuda?