日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

记录一次socket编程:String的trim函数

發布時間:2025/3/15 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 记录一次socket编程:String的trim函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

源碼:

/*** Returns a string whose value is this string, with any leading and trailing* whitespace removed.* <p>* If this {@code String} object represents an empty character* sequence, or the first and last characters of character sequence* represented by this {@code String} object both have codes* greater than {@code '\u005Cu0020'} (the space character), then a* reference to this {@code String} object is returned.* <p>* Otherwise, if there is no character with a code greater than* {@code '\u005Cu0020'} in the string, then a* {@code String} object representing an empty string is* returned.* <p>* Otherwise, let <i>k</i> be the index of the first character in the* string whose code is greater than {@code '\u005Cu0020'}, and let* <i>m</i> be the index of the last character in the string whose code* is greater than {@code '\u005Cu0020'}. A {@code String}* object is returned, representing the substring of this string that* begins with the character at index <i>k</i> and ends with the* character at index <i>m</i>-that is, the result of* {@code this.substring(k, m + 1)}.* <p>* This method may be used to trim whitespace (as defined above) from* the beginning and end of a string.** @return A string whose value is this string, with any leading and trailing white* space removed, or this string if it has no leading or* trailing white space.*/public String trim() {int len = value.length;int st = 0;char[] val = value; /* avoid getfield opcode */while ((st < len) && (val[st] <= ' ')) {st++;}while ((st < len) && (val[len - 1] <= ' ')) {len--;}return ((st > 0) || (len < value.length)) ? substring(st, len) : this;}

trim函數功能是去除首位的空格,但是需要注意的是,如果單單自身使用了trim函數,并沒有賦值給實例,則,該自身沒有去除空格。

例:

String s = "aaaa "; s.trim(); System.out.println(s+"*"); s = s.trim(); System.out.println(s+"*");

在socket編程的時候,我接收服務端傳過來的數據,用了直接trim函數,并沒有賦值給自身,因為它已經轉成去除空餓的字符串了,導致后端接收的數據一直有多余的空格。

?

總結

以上是生活随笔為你收集整理的记录一次socket编程:String的trim函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 一道本av | 伊人爱爱网 | 天天天天| 初尝黑人巨炮波多野结衣 | 亚洲熟女一区二区三区 | 一区二区三区四区在线视频 | 一区不卡av | 国产性猛交xxxⅹ交酡全过程 | 国产福利在线看 | 国产在线一区不卡 | 亚洲av永久纯肉无码精品动漫 | av毛片在线| 成年人黄色在线观看 | 欧美综合视频在线观看 | 91gao | 怡红院精品视频 | 97在线播放免费观看 | 国产三级按摩推拿按摩 | 成人免费av在线 | 少女逼逼 | 国产精品永久久久久久久久久 | 秋霞一区 | 女人洗澡一级特黄毛片 | 自拍日韩亚洲一区在线 | 亚洲一区二区三区四区av | 中文字幕免费高清 | 米奇久久 | 永久免费未满 | 国产精品亚洲第一 | 亚洲综合视频在线 | 尤物精品视频在线观看 | 亚洲精品久久久久久动漫器材一区 | 爱爱视频网址 | 在线色站 | av色网站 | 欧美午夜激情视频 | 中文字幕第十二页 | 影音先锋男人资源网站 | 欧美乱轮视频 | 福利视频大全 | 精品国产一区二区在线观看 | 中文字幕高清在线免费播放 | 三级艳丽杨钰莹三级 | 日韩性插 | 九九精品视频在线观看 | 人人澡人人爽 | 日韩中文第一页 | 色屁屁视频 | 亲切的金子餐桌片段的金子 | 啪视频免费 | 亚洲一一在线 | 亚洲国产乱 | 青青久操 | 国产精品zjzjzj在线观看 | 欧美一区永久视频免费观看 | 亚洲成人免费网站 | 亚洲人成人无码网www国产 | 午夜激情亚洲 | 激情小说中文字幕 | 女优在线观看 | 开心春色激情网 | 欧美熟妇精品一区二区 | 久久亚洲精精品中文字幕早川悠里 | 成年人免费网址 | 一级黄色片免费在线观看 | 一区二区高清在线 | 日本一卡二卡在线 | 国产香蕉在线观看 | 在线免费视频你懂的 | 久久无码视频网站 | 蜜臀av一区二区三区激情综合 | 亚洲精品在线观 | 在线看片中文字幕 | julia一区二区中文久久97 | 黄色不卡av| 日韩av在线影院 | www色网站| 久久久久久少妇 | 欧美日韩精品区别 | 久久亚洲欧洲 | 久久免费激情视频 | 香蕉视频网站在线 | 水牛影视av一区二区免费 | 午夜在线影院 | 国产精品久久久久高潮 | 久久精品天堂 | 色亚洲成人 | 日韩av一区二区在线观看 | 一区二区三区欧美 | 亚洲网站在线看 | 国产一级一片免费播放 | 国产黄色一区二区三区 | 午夜一区二区三区 | 中文字幕av网 | 深夜视频在线观看免费 | 欧美做爰猛烈床戏大尺度 | 欧美高清一区二区 | 肉大捧一进一出免费视频 | 男男黄网站 |