在Android中/ Java的的stripslashes [英] Stripslashes in Android/Java

查看:273
本文介绍了在Android中/ Java的的stripslashes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务运行和Android设备从中读取数据。我要发送的数据,由服务器大幅削减,以避免黑客攻击的问题。一旦其escapped,它被保存到数据库中。

I've a webservice running and Android devices reading data from it. The data I want to send, is slashed by the server, to avoid hacking issues. Once its escapped, it's being saved into the database.

但是,当我再次阅读本数据,它的返回是这样的:
巴巴O \\'莱利,而不是巴巴O'Riley。

But when I'm reading this data again, it's being returned like this: "Baba O\'Riley" instead of "Baba O'Riley".

我认为它的pretty正确的,而我所要做的,就是清理字符串,我得到的反斜杠像中的stripslashes PHP函数。

I think its pretty "correct" and that what I've to do, is to clean the string I get of backslashes with a function like Stripslashes in PHP.

http://es1.php.net/manual/es/function。 stripslashes.php

不过,我找不到任何功能,做到这一点在Java中。

However, I couldn't find any function to do this in Java.

任何想法?

推荐答案

您可以使用字符串<一个href=\"http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace%28java.lang.CharSequence,%20java.lang.CharSequence%29\"相对=nofollow>替换()函数。请参见替换字符串反斜杠和<一个href=\"http://stackoverflow.com/questions/6805028/how-to-replace-backward-slash-to-forward-slash-using-java\">How更换反斜线用java正斜杠?

You can use string.replace() function. See String replace a Backslash and How to replace backward slash to forward slash using java?

String replacedStr = stringname.replace("\\", "");

这篇关于在Android中/ Java的的stripslashes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆