我正在尝试从十六进制初始化一个字符串:
import java.io.*;
public class a {
public static void main (String[] args)
{
try {
PrintWriter w = new PrintWriter("something");
w.println("\u0061\u0062\u000a");
w.close();
} catch (Exception e) {};
}
}
Run Code Online (Sandbox Code Playgroud)
但看起来像"\ u000a"是一个badchar,它一直告诉我未封闭的字符串文字?
a.java:8: error: unclosed string literal
w.println("\u0061\u0062\u000a");
Run Code Online (Sandbox Code Playgroud)
知道它有什么问题吗?
运行:
%> java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Run Code Online (Sandbox Code Playgroud) (我正在使用Elasticsearch 1.5.2的新副本执行此操作)
我已经定义了一个自定义分析器,它正在工作:
curl -XPUT 127.0.0.1:9200/test -d '{
"settings": {
"index": {
"analysis": {
"tokenizer": {
"UrlTokenizer": {
"type": "pattern",
"pattern": "https?://([^/]+)",
"group": 1
}
},
"analyzer": {
"accesslogs": {
"tokenizer": "UrlTokenizer"
}
}
}
}
}
}'; echo
curl '127.0.0.1:9200/test/_analyze?analyzer=accesslogs&text=http://192.168.1.1/123?a=2#1111' | json_pp
Run Code Online (Sandbox Code Playgroud)
现在我将它应用于索引:
curl -XPUT 127.0.0.1:9200/test/accesslogs/_mapping -d '{
"accesslogs" : {
"properties" : {
"referer" : { "type" : "string", "copy_to" : "referer_domain" },
"referer_domain": {
"type": "string",
"analyzer": "accesslogs"
}
}
}
}'; echo
Run Code Online (Sandbox Code Playgroud)
从映射我可以看到它们都被应用.
现在我尝试插入一些数据,
curl 127.0.0.1:9200/test/accesslogs/ …Run Code Online (Sandbox Code Playgroud) 我有一个这样的脚本,它运行:
#!/usr/bin/env perl
error: print 0x41
Run Code Online (Sandbox Code Playgroud)
我期待这error:部分触发语法错误,但它没有。有谁知道这个语法?
我正在使用imap <c-v> <ESC>"+PAgVIM进行粘贴,但是,每次我尝试粘贴时都会得到意想不到的结果:
aa${CURSOR}aa,现在按^ V,我得到了a${PASTE_TXT}aaa,但我想要aa${PASTE_TXT}aa.
我怎样才能解决这个问题 ?
我正在尝试在这里创建一个简单的HTTP客户端,所以我尝试使用socket.sendto()和socket.recvfrom()
发送和接收消息:
所以在我的系统上启用了apache服务器,绑定到端口80:
sock = socket (AF_INET , SOCK_DGRAM)
sock.sendto ( 'GET /' , ( 127.0.0.1 , '80' ) )
message , servaddr = sock.recvfrom (255)
Run Code Online (Sandbox Code Playgroud)
陷入困境,但nc localhost 80'GET /'有效
默认情况下,python的套接字不是非阻塞的,为什么我会卡在这里?
当我看到一个调用时,我想快速跳过一个函数,在Qt Creator中你可以简单地点击它foo,它会跳转到正确的文件,右边的行
int ret = foo();
我怎么能在VS中这样做?
谢谢
我看到有人在C++类中编写这样的代码:
int foo ( int dummy )
{
this->dummy = dummy;
}
Run Code Online (Sandbox Code Playgroud)
我们应该使用这样的代码,它会导致问题吗?
我试图编译这样的东西,它似乎工作.
@update:我发布的主要是关于名称dummy和内部变量this->dummy,以及它是否导致问题
假设以下构造函数:
class Needed
{
public:
Needed () {}
Needed (const char *name) {}
};
class Dummy
{
public:
Dummy (): needed ( "Jimmy" ) {}
private:
Needed needed;
};
Run Code Online (Sandbox Code Playgroud)
那么,我needed在这里初始化了两次吗?
我使用 QTextCursor 在 QTextEdit 中插入了几张图片,现在我应该如何保存整个内容?
我的第一个想法是遍历 QTextCursor 的所有位置,但我没有找到合适的界面来使用。
使用中的示例代码:
QTextCursor cursor = ui->textEdit->textCursor();
cursor.insertImage(QImage ("/secure/Common/Pictures/icons/gimp.svg"));
ui->textEdit->setTextCursor(cursor);
QTextDocument *document = ui->textEdit->document();
QStringList images;
QTextBlock b = document->begin();
while (b.isValid()) {
for (QTextBlock::iterator i = b.begin(); !i.atEnd(); ++i) {
QTextCharFormat format = i.fragment().charFormat();
bool isImage = format.isImageFormat();
if (isImage)
{
images << format.toImageFormat().name();
qDebug() << document->resource(QTextDocument::ImageResource,
QUrl(format.toImageFormat().name())).toByteArray().size();
}
}
b = b.next();
}
Run Code Online (Sandbox Code Playgroud) 看起来Lua套接字的设置超时仅在以后工作connect,我无法使用assert (socket.connect (..)),因为我有多个服务器可以试用.
我的情况是,当一台服务器关闭(无法连接而不是不稳定的网络)时,我将使用另一台服务器,因此我必须在连接时超时.
有什么建议?
编辑
我找到了Lua TCP套接字,但有了这个,我无法检测到连接失败,
local tcp = socket.tcp()
tcp:settimeout(1)
tcp:connect(...)
Run Code Online (Sandbox Code Playgroud)