从输入流读取
我在 Android 上有一个客户端服务器应用程序。我必须将数据从客户端发送到服务器。 我发送的数据是以这种方式包装的 GPS 数据:
GeoPoint p = new GeoPoint(latitude,longitude);
geoPointsArray.add(p);
现在,一切顺利...我成功通过套接字发送数据,但在服务器上我必须获取所有这些数据并将其写入数据库。
我在服务器上读取数据的方式是这样的:
BufferedReader in=new BufferedReader(new InputStreamReader(client.getInputStream()));
String line=null;
while((line = in.readLine()) != null)
{
}
现在在 line = in.readLine()
中,我有一行 GPS 数据(纬度、经度),但我不知道如何我可以读取一个点的(纬度,经度),将其包装回地理点 p...之后读取另一个点(纬度,经度)将其放入“地理点 p”等等...然后再写数据库中的“geopoint p”!
PS:我不明白的是如何从该“行”读取数据,以便将某个点的正确纬度和经度放在数据库中。
希望我已经说得足够清楚了。我来这里是为了了解更多细节。提前谢谢你!
I have an client server application on Android.And I have to send data from client to server.
The data that I send is GPS data wrapped this way:
GeoPoint p = new GeoPoint(latitude,longitude);
geoPointsArray.add(p);
Now,everything goes fine...I succed to send the data through the socket,but at the server I have to take all this data and write it in a database.
The way that I read the data at the server is this:
BufferedReader in=new BufferedReader(new InputStreamReader(client.getInputStream()));
String line=null;
while((line = in.readLine()) != null)
{
}
Now in line = in.readLine()
, I have a line of GPS data (latitude,longitude) and I can't figure out how could I read (latitude,longitude) of a point, wrap it back in a geopoint p...after that read another (latitude,longitude) put it in "geopoint p" and so on....And after that to write "geopoint p" in a database!
P.S:What I don't understand is how to read from that "line" so that I put the correct latitude and longitude of a point together on the database.
Hope I've been clear enough.I'm here for further details.Thank u in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以以简单文本方式发送纬度/经度信息,并在服务器端进行非常简单的解析。这将是快速且容易做到的。因此,不要发送直接的 GeoPoint 对象,而是发送其中明文写入的信息,然后从管道的另一端读取它。听起来不错吗?
JQ科雷亚
Maybe you can send the Lat/Lon information on a Simple text manner and in the server side do a very simple parsing. This would be quick and easy to do. So, instead of sending an direct GeoPoint object send the info inside of it written plainly and read it the other side of the pipe. Sounds good?
JQCorreia