在java中打印经度和纬度坐标但是会出错 跟踪: 无法打开和读取文件:C:\ Users \ Amit Raturi..javame-SDK \ 8.2 \工作\ EmbeddedDevice1 \ appdb \ 00000003.iijava.io.IOException: storage_open():没有这样的文件或目录,C:\ Users \ Amit Raturi..javame-SDK \ 8.2 \工作\ EmbeddedDevice1 \ appdb \ 00000003.ii
- com / sun / midp / io / j2me / storage / RandomAccessStream..unknown。(),bci = 0
- com / sun / midp / io / j2me / storage / RandomAccessStream..unknown。(),bci = 21
- .unknown ... unknown。(),bci = 26
- .unknown ... unknown。(),bci = 8
- .unknown ... unknown。(),bci = 1
- .unknown ... unknown。(),bci = 7
- .unknown ..(),bci = 68
- com / sun / midp / midletsuite / MIDletSuiteStorage..unknown。(),bci = 58
- com / sun / midp / midletsuite / MIDletSuiteStorage..unknown。(),bci = 6
- com / sun / midp / midletsuite / MIDletSuiteStorage..unknown。(),bci = 30
- com / sun / midp / midletsuite / MIDletSuiteStorage..unknown。(),bci = 10
- .unknown ... unknown。(),bci = 3
- .unknown ... unknown。(),bci = 419
- .unknown ... unknown。(),bci = 122
- .unknown ... unknown。(),bci = 60
- .unknown ... unknown。(),bci = 194
- .unknown ... unknown。(),bci = 2
- .unknown..run(),bci = 5
- java / lang / Thread.run(),bci = 5
我的代码是:
Criteria cr = new Criteria();
@Override
public void startApp() {
int i=5;
double[] locat = null;
cr.setHorizontalAccuracy(500);
LocationProvider lp = null;
try {
lp = LocationProvider.getInstance(cr);
} catch (LocationException ex) {
Logger.getLogger(Mygpspro.class.getName()).log(Level.SEVERE, null,ex);
}
try {
locat=getLocation(lp);
} catch (Exception ex) {
Logger.getLogger(Mygpspro.class.getName()).log(Level.SEVERE,null,ex);
}
System.out.println(locat[0]);
System.out.println(locat[1]);
}
public static double[] getLocation(LocationProvider lp) throws Exception
{
double []arr = new double[3];
if(lp != null)
{
switch(lp.getState())
{
case LocationProvider.AVAILABLE:
Location l = lp.getLocation(-1);
QualifiedCoordinates c = l.getQualifiedCoordinates();
if(c != null )
{
double lat = c.getLatitude();
double lon = c.getLongitude();
double alt = c.getAltitude();
String latStr = Double.toString(lat).substring(0,7);
String lonStr = Double.toString(lon).substring(0,7);
lat = Double.parseDouble(latStr);
lon = Double.parseDouble(lonStr);
arr[0] = lat;
arr[1] = lon;
arr[2] = alt;
}
else
{
throw new Exception("Co ordinate is null!!");
}
break;
/* Other cases are handled here */
default:
break;
}
}
return arr;
}