【问题标题】:How to remove "" from the string in java?如何从java中的字符串中删除“”?
【发布时间】:2017-10-30 20:50:45
【问题描述】:
        [![While executing a command i am getting output with "" how can I supress those symbol in my output][1]][1]


          [1]: https://i.stack.imgur.com/UgZDI.png


//OutputStream out = channel.getOutputStream();
                out.write(3); // send CTRL-C
                out.flush();
                System.out.println("exit1");
                if (expect.expect("$") > -1) {
                    System.out.println("finding $");

                    contt = (expect.before);
                    if (contt != null && contt != "") {
                       output=contt.replaceAll("", " ");
                        System.out.println("afterline"+output);


                    } else {
                        contt="Error in Top Check";
                        System.out.println("Error in Top check");
                    }
//I am trying to replaceAll this string.

//我正在通过 jsch 运行命令并获得以下输出,我已将其共享为屏幕截图。我需要通过从输出中删除“”来显示它。 需要帮助

【问题讨论】:

  • 到目前为止你尝试过什么? (提示:String.replace()、Character.isISOControl(c))
  • 我已经尝试使用 repalce All.no psoitive 结果
  • 向我们展示您尝试过的代码 - 这将大大改善您的问题并显示您的努力 - 所以我们不会指出您已经尝试过的事情。 (“编辑”按钮是您的朋友!)
  • 试着改进你的问题,否则没人能帮助你。
  • 我认为您在使用 replaceAll 和引号时遇到了一些问题。检查这个:stackoverflow.com/questions/3559063/…

标签: java


【解决方案1】:

两个可行的解决方案:

1) 使用 String 类的标准 replaceAll() 方法,例如:

String a = a.replaceAll("\"","");

2) 使用 Apache StringUtils 替换方法 例如:

String a = StringUtils.replace(a,"\"",""");

【讨论】:

  • 这不是真正的问题,而是一些无法打印的字符作为响应
猜你喜欢
  • 2015-10-30
  • 2014-01-08
  • 2011-08-07
  • 1970-01-01
  • 1970-01-01
  • 2015-02-19
  • 1970-01-01
  • 2019-03-21
  • 2015-05-13
相关资源
最近更新 更多