当使用readLine()接收数据时,即使我在发送消息时使用.flush在消息末尾添加了"\n",但读取我的消息的while循环仍会阻塞.只有在关闭套接字连接时,才会离开循环.
这是客户端代码:
bos = new BufferedOutputStream(socket.
getOutputStream());
bis = new BufferedInputStream(socket.
getInputStream());
osw = new OutputStreamWriter(bos, "UTF-8");
osw.write(REG_CMD + "\n");
osw.flush();
isr = new InputStreamReader(bis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String response = "";
String line;
while((line = br.readLine()) != null){
response += line;
}
Run Code Online (Sandbox Code Playgroud)
和服务器的代码:
BufferedInputStream is;
BufferedOutputStream os;
is = new BufferedInputStream(connection.getInputStream());
os = new BufferedOutputStream(connection.getOutputStream());
isr = new InputStreamReader(is);
String query= "";
String line;
while((line = br.readLine()) != null){
query+= line;
}
String response = executeMyQuery(query); …Run Code Online (Sandbox Code Playgroud) 如何使用ormlite编写查询而不是使用.create或其他任何类似的东西?你能告诉我这个简单的例子:
SELECT name FROM client
Run Code Online (Sandbox Code Playgroud)
编辑,因为我无法回答自己:我想我必须再搜索一下,无论如何我发现如何使用QueryBuilder这样做:
newDao.query(newDao.queryBuilder().where.eq("name",valueofname)
Run Code Online (Sandbox Code Playgroud)
如果有人知道如何编写完整的查询,那么,我会坚持使用这个解决方案
我正在制作一个电话号码验证器,所有号码都应该168以9位开头,然后是9位数123456789.总的来说,电话号码应该只有12位数.
我试过这个
$phoneNumber = '168921500789';
if( preg_match( "/^\168[0-9]{9}$/", $phoneNumber ) ){
echo "Valid number";
} else {
echo "Invalid number";
}
Run Code Online (Sandbox Code Playgroud)
当我运行脚本时,该数字无效.如何使脚本只取12个必须以168?开头的数字.
我看不出我的问题在哪里.我尝试过多种方式,但我仍然遇到同样的问题.正如标题所说,我有一个div成为div.当孩子使用浮动时,他离开父母div.即使事实并非如此,在设置边框进行检查时,这就是我所看到的.
#feed{
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
width: 70%;
float: center;
}
.news{
margin:auto;
margin-top: 10px;
padding-bottom: 5px;
border: 1px solid;
}
.newsContent{
margin-top: 5px;
margin-left:5px;
margin-right:5px;
background-color:red;
}
.newsContent p{
margin-left: 5px;
margin-right: 5px;
}
.newsDate{
width: 20%;
margin-top: 5px;
margin-left:5px;
margin-right:5px;
float: right;
background-color:red;
}
.newsDate p{
text-align: center;
}
Run Code Online (Sandbox Code Playgroud)
和我的HTML代码:
<div id="feed">
<div class="news">
<div class="newsContent">
<p> ici nouveauté </p>
</div>
<div class="newsDate">
<p> ici date </p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
谢谢.