- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
令人惊讶的是,Qt5 弃用了以前版本中存在的 StringBuilder
类。我的另一个选择是使用 QTextStream
,这并不方便,因为我必须传入它写入的缓冲区(例如 QFile
、QString
) .
C++ (std::stringstream
)、C# (StringBuilder
) 和 Java (StringBuffer
) 都有这些类。 Qt 怎么样?
最佳答案
QStringBuilder
未弃用。来自 Qt docs :
In 4.6, an internal template class QStringBuilder has been added along with a few helper functions. This class is marked internal and does not appear in the documentation, because you aren't meant to instantiate it in your code. Its use will be automatic, as described below. The class is found in src/corelib/tools/qstringbuilder.cpp if you want to have a look at it.
他们的代码示例:
#include <QStringBuilder>
QString hello("hello");
QStringRef el(&hello, 2, 3);
QLatin1String world("world");
QString message = hello % el % world % QChar('!');
你可以使用你需要的 C++ 中的任何东西,比如 std::stringstream
。
关于c++ - Qt5 是否有类似于 StringBuilder 或 StringBuffer 的类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35235762/
为什么下一行没有给出编译时错误? StringBuffer sb = new StringBuffer(new StringBuffer()); 我在网上查了很多也找不到原因。不仅如此,它还允许 St
我在 http get 请求中使用了下面的代码,但是我从返回中得到的是 null。我不知道为什么。 public static String getResponseFromGetUrl(Strin
错误是: Unreachable statement in line StringBuffer buffer = new StringBuffer() 这是我的代码: public void
当 StringBuffer 超出容量时,是否会创建一个新的 StringBuffer 对象,还是仍然是旧的? class Test{ public static void main(String[]
1.我对这两者感到困惑,如果有的话,它们有不同的功能吗? StringBuffer(CharSequence chars) 和 StringBuffer(String str) 2。 String 和
阅读本文后 - What does 'synchronized' mean?我仍然无法理解为什么 StringBuffer 在线程安全环境中会比 StringBuilder 慢。 StringBuff
考虑以下代码 final class immudemo { private static final StringBuffer bf = new StringBuffer("Yaxita"
Groovy支持用于创建StringBuilder / StringBuffer的文字语法,而不是通常的语法 def sb = new StringBuilder() 但是,我似乎无法记住(或在Goo
这是我尝试使用数组构建 stringBuffer。我该如何解决这个问题? import java.util.ArrayList; public class StringBufferProj { pub
我对官方 Javadoc 的说法感到困惑 public StringBuffer replace(int start, int end, String str) Replaces the charac
与将所有数组项附加到 StringBuffer 然后打印相比,为什么在循环中打印数组项需要更多时间? 在此,我在循环中打印了数组项。 public static void main (String[]
我目前正在使用很多这样的内容来重构应用程序: StringBuffer buff1 = new StringBuffer(""); buff1.append("some value A"); buff
我有一个简单的函数,用于连接到服务器并将响应作为字符串返回。当返回的数据量较小但响应较大时,它可以正常工作。它不会完整存储服务器返回的响应字符串,并以...结尾。令人惊讶的是,system.out.p
我对编程还很陌生,需要一些帮助。我正在学习如何使用 StringBuffer 类,并且编写了一个简单的代码。但是,当我尝试运行该程序时,我不断收到错误消息“找不到符号”。任何建议都会很棒!谢谢! pu
在ArrayList中,添加操作是摊销操作。因此,在阅读 StringBuffer 时,我想到了为什么 StringBuffer 不进行摊销。假设我对字符串缓冲区对象使用追加操作,那么它应该能够在其底
我正在尝试在字符串中切换 $ 及其右侧的字符。我不允许使用 char[],所以我决定使用 StringBuffer。但是,当我尝试使用 H$E 之类的内容运行代码时,它会输出 HE$H$E 我不知道额
这个问题已经有答案了: Difference between StringBuilder and StringBuffer (33 个回答) 已关闭 9 年前。 很多人都提到过Java中StringB
我正在尝试从InputStream 中读取一些数据,然后将它们放入StringBuffer 中进行打印。 我把这段代码放在main方法中。 我的问题是,只有在调试代码时才打印 StringBuffer
我正在运行此代码: public class testttt { public static void main(String[] args){ ArrayList listOne = new
我有以下代码: public class MyLogger { private StringBuilder logger = new StringBuilder(); public voi
我是一名优秀的程序员,十分优秀!