當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Processing Client.clear()用法及代碼示例


Processing, 類Client中的clear()用法介紹。

用法

  • client.clear()

參數

  • client (Client) 客戶端類型的任何變量

返回

  • void

說明

清空緩衝區,刪除存儲在那裏的所有數據。

例子

// Creates a client that listens for input until it gets a 
// linefeed and then throws the rest of the input away.

import processing.net.*; 
Client myClient; 
String inString;
byte interesting = 10;

void setup() { 
  size (300, 100);
  // Connect to the local machine at port 10002.
  // This example will not run if you haven't
  // previously started a server on this port.
  myClient = new Client(this, "127.0.0.1", 10002); 
} 

void draw() { 
  if (myClient.available() > 0) { 
    background(0); 
    // Read input until we get a byte of value 10 (ASCII linefeed):
    inString = myClient.readStringUntil(interesting); 
    println(inString); 
    // Throw away the rest of the input:
    myClient.clear();
  }
} 

相關用法


注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 Client.clear()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。