New I/0 Functionality for JavaTM 2 Standard Edition 1.4

印尼稻米收成与粮食安全数据集2026年 本数据集收录印度尼西亚2026年水稻收成与粮食安全遥测数据,包含10000条稻米农业收成产量与粮食安全监测记录,围绕印尼国家粮食安全体系中的核心作物水稻展开。稻米是印尼逾两亿人口的主粮,其收成波动直接影响国家粮食安全与进口政策,本数据集将种植区域、收成产量、气候与土壤相关遥测指标整合为结构化表格,可支撑粮食产量预测、收成影响因素分析、区域粮食安全评估与农业政策模拟等研究任务。典型应用场景包括:农业时间序列产量预测模型构建、气候因子与水稻收成的关联分析、省份与地区层面的粮食自给率测算、粮食安全风险预警指标设计,也可作为农业经济、粮食政策与数据科学交叉课程的教学素材。数据为2026年最新版,规模约1.2MB、单CSV结构规整,字段命名清晰,适合Python、Pandas、Scikit-learn等主流工具链直接使用,便于开展探索性分析、可视化与机器学习全流程练习。重要说明:本数据为遥测整理数据,分析结论以数据集文档口径为准,农业决策请结合官方统计综合研判。许可:CC0公有领域,可自由使用与二次分发。 立即下载

New I/0 Functionality for JavaTM 2 Standard Edition 1.4

John Zukowski
October, 2001

Back in January 2000, while many people were arguing about whether the year 2000 was the last or first year of the century, life began for JSR 51 as an approved Java Specification Request (JSR). The name of that JSR is New I/O APIs for the Java Platform. Many people think of the new capabilities as just offering non-blocking I/O operations. However, the new features introduced into the JavaTM 2 Platform, Standard Edition (J2SETM), version 1.4 Beta, include many other new and interesting features. While the API certainly will offer support for scalable I/O operations for both sockets and files, you'll also find a regular expression package for pattern matching, encoders and decoders for character set conversions, and improved file system support like file locking and memory mapping. All four of these new features will be covered in this article.

Note: The Java Native Interface (JNI) changes made to support the New I/O operations will not be covered. For information on these changes, see the Resources section at the end of this article.

Buffers

Starting from the simplest and building up to the most complex, the first improvement to mention is the set of Buffer classes found in the java.nio package. These buffers provide a mechanism to store a set of primitive data elements in an in-memory container. Basically, imagine wrapping a combined DataInputStream/DataOutputStream around a fixed-size byte array and then only being able to read and write one data type, like char, int, or double. There are seven such buffers available:

  • ByteBuffer
  • CharBuffer
  • DoubleBuffer
  • FloatBuffer
  • IntBuffer
  • LongBuffer
  • ShortBuffer

The ByteBuffer actually supports reading and writing the other six types, but the others are type specific. To demonstrate the use of a buffer, the following snippet converts a String to a CharBuffer and reads a character at a time. You convert the String to a CharBuffer with the wrap method, then get each letter with the get method.

CharBuffer buff = CharBuffer.wrap(args[0]);
for (int i=0, n=buff.length(); i<n; i++) {
  System.out.println(buff.get());
}

When using buffers, it is important to realize there are different sizing and positioning values to worry about. The length method is actually non-standard, specific to CharBuffer. There is nothing wrong with it, but it really reports the remaining length, so if the position is not at the beginning, the reported length will not be the buffer length, but the number of remaining characters within the buffer. In other words, the above loop can also be written as follows.

CharBuffer buff = CharBuffer.wrap(args[0]);
for (int i=0; buff.length() > 0; i++) {
  System.out.println(buff.get());
}

Getting back to the different sizing and positioning values, the four values are known as mark, position, limit, and capacity:

  • mark -- setable position with mark method that can be used to reset the position with reset, <= position, >= 0
  • position -- current read/write position within buffer, <= limit
  • limit -- index of first element that should not be read, <= capacity
  • capacity -- size of buffer, >= limit

The position is an important piece of information to keep in mind when reading from and writing to a buffer. For instance, if you want to read what you just wrote you must move the position to where you want to read from, otherwise, you'll read past the limit and get whatever just happens to be there. This is where the flip method comes in handy, changing the limit to the current position and moving the current position to zero. You can also rewind a buffer to keep the current limit and move the position back to zero. For example, removing the flip call from the following snippet will get back a space, assuming nothing was put in the buffer originally.

buff.put('a');
buff.flip();
buff.get();

The wrap mechanism shown above is an example of a non-direct buffer. Non-direct buffers can also be created and sized with the allocate method, essentially wrapping the data into an array. At a slightly higher creation cost, you can also create a contiguous memory block, also called a direct buffer, with the allocateDirect method. Direct buffers rely on the system's native I/O operations to optimize access operations.

Mapped Files

There is one specialized form of direct ByteBuffer known as a MappedByteBuffer. This class represents a buffer of bytes mapped to a file. To map a file to a MappedByteBuffer, you first must get the channel for a file. A channel represents a connection to something, such as a pipe, socket, or file, that can perform I/O operations. In the case of a FileChannel, you can get one from a FileInputStream, FileOutputStream, or RandomAccessFile through the getChannel method. Once you have the channel, you map it to a buffer with map, specifying the mode and portion of the file you want to map. The file channel can be opened read-only (MAP_RO), copy-on-write (MAP_COW), or read-write (MAP_RW).

Here's the basic process for creating a read-only MappedByteBuffer from a file:

String filename = ...;
FileInputStream input = new 
  FileInputStream(filename);
FileChannel channel = input.getChannel();
int fileLength = (int)channel.size();
MappedByteBuffer buffer = 
  channel.map(FileChannel.MAP_RO, 0, fileLength);

You'll find the channel-related classes in the java.nio.channels package.

Once the MappedByteBuffer has been created, you can access it like any other ByteBuffer. In this particular case though, it is read-only, so any attempt to put something will throw an exception, NonWritableChannelException in this case. If you need to treat the bytes as characters, you must convert the ByteBuffer into a CharBuffer through the use of a character set for the conversion. This character set is specified by the Charset class. You then decode the file contents through the CharsetDecoder class. There is also a CharsetEncoder to go in the other direction.

// ISO-8859-1  is ISO Latin Alphabet #1
Charset charset = Charset.forName("ISO-8859-1");
CharsetDecoder decoder = charset.newDecoder();
CharBuffer charBuffer = decoder.decode(buffer);

These classes are found in the java.nio.charset package.

Regular Expressions

Once you've mapped the input file to a CharBuffer, you can do pattern matching on the file contents. Think of running grep or wc on the file to do regular expression matching or word counting, respectively. That's where the java.util.regex package comes into play and the Pattern and Matcher classes get used.

The Pattern class provides a whole slew of constructs for matching regular expressions. Basically, you provide the pattern as a String. See the class documentation for full details of the patterns. Here are some samples to get you started:

  • Line pattern, any number of characters followed by carriage return and/or line feed: .*/r?/n or .*$
  • Series of numbers: [0-9]* or /d*
  • A control character {cntrl}
  • An upper or lowercase US-ASCII character, followed by white space, followed by punctuation: [{lower}{upper}]/s{punct}

When you provide the pattern, you tell the Pattern class to compile it. Because pattern matching tries to find the largest possible match, in the case of the end-of-line character ($), you don't want to match the entire file to the end of it. You must use the compile option of MULTILINE. There are other options for tasks like case-insensitive matching and Unicode-aware case folding, among a few others. So, if your pattern was for the line pattern above, the code would look like such:

Pattern linePattern = Pattern.compile(".*$", 
  Pattern.MULTILINE);

When it is time to match the pattern, you call the matcher method to get a Matcher back. From this, you can find out if the pattern matches or find and get the matching piece with group, or you can split the string by providing the break pattern, and getting the individual pieces back with split. For instance, the following is a framework for reading a line at a time and getting words out of each line.

Matcher matcher = p.matcher(aString);
Pattern wordBreakPattern = 
  Pattern.compile("[{space}{punct}]");
// Loop through the lines
while (lineMatcher.find()) {
  CharSequence line = lineMatcher.group();
  String words[] = wordBreakPattern.split(line);

  // For each word
  for (int i=0, n=words.length; i<n; i++) {
    // Lines with just break characters return an empty string
    if (words[i].length() > 0) {
      System.out.println(":" + words[i] + ":");
    }
  }
}

There is also a shortcut for matching with boolean b = Pattern.matches(".*/r?/n", aString), but it isn't efficient for when you need to recheck for matches as the Pattern is not compiled.

To combine all the previously mentioned skills, the following example performs a word/line count on file passed into the program:

import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
import java.util.*;
import java.util.regex.*;

public class WordCount {
  public static void main(String args[]) throws 
    Exception { 
      String filename = args[0];

    // Map File from filename to byte buffer
    FileInputStream input = new 
      FileInputStream(filename);
    FileChannel channel = input.getChannel();
    int fileLength = (int)channel.size();
    MappedByteBuffer buffer = 
      channel.map(FileChannel.MAP_RO, 0, 
        fileLength);

    // Convert to character buffer
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();
    CharBuffer charBuffer = decoder.decode(buffer);

    // Create line pattern
    Pattern linePattern = Pattern.compile(".*$",
      Pattern.MULTILINE);

    // Create word pattern
    Pattern wordBreakPattern = 
      Pattern.compile("[{space}{punct}]");

    // Match line pattern to buffer
    Matcher lineMatcher = 
      linePattern.matcher(charBuffer);

    Map map = new TreeMap();
    Integer ONE = new Integer(1);

    // For each line
    while (lineMatcher.find()) {
      // Get line
      CharSequence line = lineMatcher.group();

      // Get array of words on line
      String words[] = wordBreakPattern.split(line);

      // For each word
      for (int i=0, n=words.length; i<n; i++) {
        if (words[i].length() > 0) {
          Integer frequency = 
            (Integer)map.get(words[i]);
          if (frequency == null) {
            frequency = ONE;
          } else {
            int value = frequency.intValue();
            frequency = new Integer(value + 1);
          }
          map.put(words[i], frequency);
        }
      }
    }
    System.out.println(map);
  }
}

For additional information about the regular expression library, see the Regular Expressions and the Java Programming Language article referenced in the Resources.

Socket Channels

Moving on from file channels takes us to channels for reading from and writing to socket connections. These channels can be used in a blocking or non-blocking fashion. In the blocking fashion, they just replace the call to connect or accept, depending on whether you are a client or a server. In the non-blocking fashion, there is no equivalent.

The new classes to deal with for basic socket reading and writing are the InetSocketAddress class in the java.net package to specify where to connect to, and the SocketChannel class in the java.nio.channels package to do the actual reading and writing operations.

Connecting with InetSocketAddress is very similar to working with the Socket class. All you have to do is provide the host and port:

String host = ...;
InetSocketAddress socketAddress = new 
  InetSocketAddress(host, 80);

Once you have the InetSocketAddress, that's where life changes. Instead of reading from the socket's input stream and writing to the output stream, you need to open a SocketChannel and connect it to the InetSocketAddress:

SocketChannel channel = SocketChannel.open();
channel.connect(socketAddress);

Once connected, you can read from or write to the channel with ByteBuffer objects. For instance, you can wrap a String in a CharBuffer with the help of an CharsetEncoder to send an HTTP request:

Charset charset = Charset.forName("ISO-8859-1");
CharsetEncoder encoder = charset.newEncoder();
String request = "GET / /n/r/n/r";
channel.write(encoder.encode(CharBuffer.wrap(request)));

You can then read the response from the channel. Since the response for this HTTP request will be text, you'll need to convert that response into a CharBuffer through a CharsetDecoder. By creating just a CharBuffer to start, you can keep reusing the object to avoid unnecessary garbage collection between reads:

ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
CharBuffer charBuffer = CharBuffer.allocate(1024);
while ((channel.read(buffer)) != -1) {
  buffer.flip();
  decoder.decode(buffer, charBuffer, false);
  charBuffer.flip();
  System.out.println(charBuffer);
  buffer.clear();
  charBuffer.clear();
}

The following program connects all these pieces to read the main page of a Web site through an HTTP request. Feel free to save the output to a file to compare the results to viewing the page with a browser.

import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;


public class ReadURL {
  public static void main(String args[]) {
    String host = args[0];
    SocketChannel channel = null;

    try {

      // Setup
      InetSocketAddress socketAddress = 
        new InetSocketAddress(host, 80);
      Charset charset = 
        Charset.forName("ISO-8859-1");
      CharsetDecoder decoder = 
        charset.newDecoder();
      CharsetEncoder encoder = 
        charset.newEncoder();

      // Allocate buffers
      ByteBuffer buffer = 
        ByteBuffer.allocateDirect(1024);
      CharBuffer charBuffer = 
        CharBuffer.allocate(1024);

      // Connect
      channel = SocketChannel.open();
      channel.connect(socketAddress);

      // Send request
      String request = "GET / /n/r/n/r";
      channel.write(encoder.encode(CharBuffer.wrap(request)));

      // Read response
      while ((channel.read(buffer)) != -1) {
        buffer.flip();
        // Decode buffer
        decoder.decode(buffer, charBuffer, false);
        // Display
        charBuffer.flip();
        System.out.println(charBuffer);
        buffer.clear();
        charBuffer.clear();
      }
    } catch (UnknownHostException e) {
      System.err.println(e);
    } catch (IOException e) {
      System.err.println(e);
    } finally {
      if (channel != null) {
        try {
          channel.close();
        } catch (IOException ignored) {
        }
      }
    }
  }
}

Non-Blocking Reads

Now comes the interesting part, and what people are most interested in in the new I/O packages. How do you configure the channel connection to non-blocking? The basic step is to call the configureBlocking method on the opened SocketChannel, and pass in a value of false. Once you call the connect method, the method now returns immediately.

String host = ...;
InetSocketAddress socketAddress = 
  new InetSocketAddress(host, 80);
channel = SocketChannel.open();
channel.configureBlocking(false);
channel.connect(socketAddress);

Once you have a non-blocking channel, you then have to figure out how to actually work with the channel. The SocketChannel is an example of a SelectableChannel. These selectable channels work with a Selector. Basically, you register the channel with the Selector, tell the Selector what events you are interested in, and it notifies you when something interesting happens.

To get a Selector instance, just call the static open method of the class:

Selector selector = Selector.open();

Registering with the Selector is done through the register method of the channel. The events are specified by fields of the SelectionKey class. In the case of the SocketChannel class, the available operations are OP_CONNECT, OP_READ, and OP_WRITE. So, if you were interested in read and connection operations, you would register as follows:

channel.register(selector, 
  SelectionKey.OP_CONNECT | SelectionKey.OP_READ);

At this point, you have to wait on the selector to tell you when events of interest happen on registered channels. The select method of the Selector will block until something interesting happens. To find this out, you can put a while (selector.select() > 0) loop in its own thread and then go off and do your own thing while the I/O events are being processed. The select method returns when something happens, where the value returned is the count of channels ready to be acted upon. This value doesn't really matter though.

Once something interesting happens, you have to figure out what happened and respond accordingly. For the channel registered here with the selector, you expressed interest in both the OP_CONNECT and OP_READ operations, so you know it can only be one of those events. So, what you do is get the Set of ready objects through the selectedKeys method, and iterate. The element in the Set is a SelectionKey, and you can check if it isConnectable or isReadable for the two states of interest.

Here's the basic framework of the loop so far:

while (selector.select(500) > 0) {
  // Get set of ready objects
  Set readyKeys = selector.selectedKeys();
  Iterator readyItor = readyKeys.iterator();

  // Walk through set
  while (readyItor.hasNext()) {

    // Get key from set
    SelectionKey key = 
      (SelectionKey)readyItor.next();

    // Remove current entry
    readyItor.remove();

    // Get channel
    SocketChannel keyChannel = 
      (SocketChannel)key.channel();

    if (key.isConnectable()) {

    } else if (key.isReadable()) {

    }
  }
}

The remove method call requires a little explanation. The ready set of channels can change while you are processing them. So, you should remove the one you are processing when you process it. There's also a timeout setup here for the select call so it doesn't wait forever if there is nothing to do. There's also a call to get the channel from the key in there. You'll need that for each operation.

For the sample program here you're doing the equivalent of reading from an HTTP connection, so upon connection you need to send the initial HTTP request. Basically, once you know the connection is made, you send a GET request for the root of the site. When the selector reports that the channel is connectable, it may not have finished connecting yet. So, you should always check if the connection is pending through isConnectionPending and call finishConnect if it is. Once connected, you can write to the channel, but must use a ByteBuffer, not the more familiar I/O streams.

Here's what the connection code looks like:

// OUTSIDE WHILE LOOP
Charset charset = 
     Charset.forName("ISO-8859-1");
CharsetEncoder encoder = charset.newEncoder();

// INSIDE if (channel.isConnectable())
// Finish connection
if (keyChannel.isConnectionPending()) {
  keyChannel.finishConnect();
}

// Send request
String request = "GET / /n/r/n/r";
keyChannel.write
     (encoder.encode(CharBuffer.wrap(request)));

The reading from a socket channel is just like from a file channel. There is one exception though. It is more likely that the buffer may not be full when reading from a socket. Not a big deal though, as you are just going to read what is ready.

// OUTSIDE WHILE LOOP
CharsetDecoder decoder = charset.newDecoder();
ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
CharBuffer charBuffer = CharBuffer.allocate(1024);

// INSIDE if (channel.isReadable())
// Read what's ready in response
keyChannel.read(buffer);
buffer.flip();

// Decode buffer
decoder.decode(buffer, charBuffer, false);

// Display
charBuffer.flip();
System.out.print(charBuffer);

// Clear for next pass
buffer.clear();
charBuffer.clear();

Add in the necessary exception handling code and you have your socket reader. Be sure to close the channel in the finally clause to make sure its resources are released, even if there is an exception. Here's the complete client code:

import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
import java.util.*;


public class NonBlockingReadURL {
  static Selector selector;

  public static void main(String args[]) {
    String host = args[0];
    SocketChannel channel = null;

    try {

      // Setup
      InetSocketAddress socketAddress = 
        new InetSocketAddress(host, 80);
      Charset charset = 
        Charset.forName("ISO-8859-1");
      CharsetDecoder decoder = 
        charset.newDecoder();
      CharsetEncoder encoder = 
        charset.newEncoder();

      // Allocate buffers
      ByteBuffer buffer = 
        ByteBuffer.allocateDirect(1024);
      CharBuffer charBuffer = 
        CharBuffer.allocate(1024);

      // Connect
      channel = SocketChannel.open();
      channel.configureBlocking(false);
      channel.connect(socketAddress);

      // Open Selector
      selector = Selector.open();

      // Register interest in when connection
      channel.register(selector, 
        SelectionKey.OP_CONNECT | 
          SelectionKey.OP_READ);

      // Wait for something of interest to happen
      while (selector.select(500) > 0) {
        // Get set of ready objects
        Set readyKeys = selector.selectedKeys();
        Iterator readyItor = readyKeys.iterator();

        // Walk through set
        while (readyItor.hasNext()) {

          // Get key from set
          SelectionKey key = 
            (SelectionKey)readyItor.next();

          // Remove current entry
          readyItor.remove();

          // Get channel
          SocketChannel keyChannel = 
            (SocketChannel)key.channel();

          if (key.isConnectable()) {

            // Finish connection
            if (keyChannel.isConnectionPending()) {
              keyChannel.finishConnect();
            }

            // Send request
            String request = 
                 "GET / /n/r/n/r";
            keyChannel.write(encoder.encode(
              CharBuffer.wrap(request)));

          } else if (key.isReadable()) {

            // Read what's ready in response
            keyChannel.read(buffer);
            buffer.flip();

            // Decode buffer
            decoder.decode(buffer, 
              charBuffer, false);

            // Display
            charBuffer.flip();
            System.out.print(charBuffer);

            // Clear for next pass
            buffer.clear();
            charBuffer.clear();

          } else {
            System.err.println("Ooops");
          }
        }
      }
    } catch (UnknownHostException e) {
      System.err.println(e);
    } catch (IOException e) {
      System.err.println(e);
    } finally {
      if (channel != null) {
        try {
          channel.close();
        } catch (IOException ignored) {
        }
      }
    }
    System.out.println();
  }
}

Non-Blocking Servers

The final piece is having a Web server use the NIO package. With the new I/O capabilities, you can create a Web server that does not require one thread per connection. You can certainly pool threads for long processing tasks, but all you have to do is select and wait for something to do, not have all the threads waiting separately.

The basic setup of the server using channels involves you calling bind to connect a ServerSocketChannel to a InetSocketAddress.

ServerSocketChannel channel = 
  ServerSocketChannel.open();
channel.configureBlocking(false);
InetSocketAddress isa = 
  new InetSocketAddress(port);
channel.socket().bind(isa);

Everything else is the same as the client reading, except this time you need to register the OP_ACCEPT key, and check for isAcceptable when the selector notifies you of the event. It is that simple.

The following code example shows just how simple this is. It is your basic single-threaded server, sending back a canned text message for each request. Just use telnet to connect to port 9999 and see the response.

import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.*;

public class Server {
  private static int port = 9999;
  public static void main(String args[]) 
      throws Exception {
    Selector selector = Selector.open();

    ServerSocketChannel channel = 
      ServerSocketChannel.open();
    channel.configureBlocking(false);
    InetSocketAddress isa = 
      new InetSocketAddress(port);
    channel.socket().bind(isa);

    // Register interest in when connection
    channel.register(selector, 
      SelectionKey.OP_ACCEPT);

    // Wait for something of interest to happen
    while (selector.select() > 0) {
      // Get set of ready objects
      Set readyKeys = selector.selectedKeys();
      Iterator readyItor = readyKeys.iterator();

      // Walk through set
      while (readyItor.hasNext()) {

        // Get key from set
        SelectionKey key = 
          (SelectionKey)readyItor.next();

        // Remove current entry
        readyItor.remove();

        if (key.isAcceptable()) {
          // Get channel
          ServerSocketChannel keyChannel = 
            (ServerSocketChannel)key.channel();

          // Accept request
          Socket socket = keyChannel.accept();

          // Return canned message
          PrintWriter out = new PrintWriter(
            socket.getOutputStream(), true);
          out.println("Hello, NIO");
          out.close();
        } else {
          System.err.println("Ooops");
        }
      }
    }
    // Never ends
  }
}

After accepting the request, you could get the channel from the socket, make it non-blocking, and register that with the selector, too. This framework just provides the basics of using the NIO classes within a Web server. For additional information about creating a multi-threaded server, see the JavaWorld article referenced in the Resources section.

Conclusion

The New I/O features introduced to the J2SE version 1.4 Beta release provide exciting new ways to improve the performance of your programs. By taking advantage of the new capabilities, not only will they be faster but they can be much more scalable because you won't have to worry about tasks like one thread per connection. This is especially important on the server side, greatly increasing the possible number of simultaneous connections supported.

Note: If you look at the list of capabilities in JSR 51, you'll notice there is mention of scanning and formatting support, similar to C's printf. This feature didn't make the 1.4 beta release and will be saved for a later version.

 

企业数字化转型AI大模型赋能智能体平台及AI场景应用规划方案(生态合作版).pptx 立即下载

相关推荐

智慧环保生态保护行业可信数据空间应用规划方案(技术方案版).pptx

智慧环保生态保护行业可信数据空间应用规划方案(技术方案版).pptx

New I/0 Functionality for JavaTM 2 Standard Edition 1.4 (转)

New I/0 Functionality for JavaTM 2 Standard Edition 1.4 (转)[@more@]New I/0 Functionality for JavaTM 2 Standard Edi...

csd3176的博客 119

MCGS的Http协议驱动,支持http协议

硬件配置 参数设置 设备属性 设备命令 通讯状态 附录 #HTTP 1、 设备简介 驱动类型 该驱动为独立设备,直接添加构件即可,不需要挂载到父设备下 通讯协议 采用标准HTTP1.1协议 通讯方式 驱动构件为客户端。 2、 硬件连接 本软件在通讯之前,请保证通讯连接正确。通讯连接方式:采用标准的RJ45接口的以太网接线(对调网线或使用HUB交换)。 3、 设备通讯参数 本设备为独立设备,无父设备参数 4、 设备构件参数设置 “HTTP设备”参数设置如下: <1> 内部属性: 构建url信息。 <2> 最小采集周期:本软件对设备进行操作的时间周期,单位为ms,默认为100ms。 <3> 通讯等待时间:通讯数据接收等待时间,默认设置为200ms,当采集速度要求较高或数据量较大时,设置值可适当减小或增大。 <4> HttpHead:http head添加需要的字段,不需要添加http head时值为空,默认不添加。 5、 设备命令 本设备构件提供设备命令,用于进行相应的操作,设备命令的格式如下: 设备命令 命令介绍 GetHttpHead 格式1 GetHttpHead(headStr) 用途 获取http head参数 参数 headStr 参数可以为字符型变量、字符串常量 例1 !SetDevice(设备0,6,"GetHttpHead(headStr)") 获取http head数据保存到headStr中 SetHttpHead 格式1 SetHttpHead(headStr) 用途 设置http head参数 参数 headStr 参数可以为字符型变量、字符串常量

The Science of JavaTM Sound Technology

  The Science of JavaTM Sound TechnologyBy Michael D. Meloan(June 1999) Sound creates mood, triggers memories, and in conjunction with visual imagery weaves whole worlds of fantasy. Sound is t

CanFly的专栏 2653

手把手教你做基于stm32的红外、语音、按键智能灯光控制(上)

这次项目使用的板子是stm32f103c8t6最小系统板,这个板子在tb上都能够买到,随便一个最小系统板都可以,== 注意在买最小系统板的时候需要买一个stlink下载器来下载程序。显示模块是使用的0.96英寸的OLED屏幕,注意是使用的IIC通信协议的OLED屏幕,不是使用SPI总线协议的。这次写的代码还顺便集成了检测温湿度的功能,所以要使用DHT11温湿度传感器,来采集温度。本文所设计的基于单片机的灯光控制系统主要由模式选择功能、手动模式和自动模式组成。LED灯自然就是要控制的部件了。

nbbskk的博客 6559

2023 ICRA《Visual Language Maps for Robot Navigation》阅读笔记

视觉语言导航可以使用预先训练的现有的视觉语言模型来将图像与对象目标的自然语言描述相匹配,但它与绘制环境的过程仍然脱节,缺乏经典几何地图的空间精度。为了解决这个问题,我们提出了VLMaps,这是一种空间地图表示,它将预训练的视觉语言特征与物理世界的3D重建直接融合在一起。VLMaps可以使用标准探索方法从机器人上的视频馈送中自主构建,并在没有额外标记数据的情况下实现地图的自然语言索引。具体来说,当与大型语言模型(LLM)相结合时,VLMaps可以用于。

qq_44100524的博客 1992

jar-The Java Archive Tool

jar-The Java Archive ToolCombines multiple files into a single JAR archive file. SYNOPSISjar [ options ] [manifest] destination input-file [input-files]DESCRIPTIONThe jar tool is a java

CanFly的专栏 1786

STM32实战开发(66):STM32图像处理开发教程

随着物联网、人工智能和嵌入式技术的不断发展,图像处理技术在嵌入式系统中的应用越来越广泛。图像处理不仅在视觉识别、安防监控、智能家居等领域中发挥着重要作用,也在工业自动化、医疗成像、无人驾驶等高科技领域中占据重要地位。而STM32凭借其强大的硬件性能和丰富的外设支持,成为了许多图像处理应用的理想平台。

2201_76125393的博客 1450

Compressing and Decompressing Data using JavaTM APIs

Compressing and Decompressing Data using JavaTM APIsby Qusay H. Mahmoud with contributions from Konstantin KladkoFebruary 2002 Many sources of information contain redundant data or data that adds

CanFly的专栏 1733

lammps教程:实例讲解npt、nvt系综的选择

对于lammps新手来说,系综的选择令人困惑,到底是应该用nvt系综还是npt系综? 我在初学lammps时就被这个问题困扰了很久。如果去问别人,可能会告诉你一个答案:根据模拟需要确定。 其实和没说一样。 到底如何确定系综,确实不是一句两句能够说清楚的,不同的体系、不同的模拟目的要选择不同的系综。 前几天遇到的一个合金的模拟案例,比较有代表性,分享出来供大家参考。 建模方法和之前介绍过的高熵合金建模方法类似,先建立单晶模型,然后使用替换原子的命令获得合金结构。 建模完成后,按照常规,先上nvt系综进行驰豫

lammps_jiayou的博客 9770

卷积码Viterbi译码算法原理及C语言实现

具体而言,卷积码的编码过程是将输入数据和编码器中的状态进行异或操作,输出码字为各个状态对应的结果。Viterbi译码算法是一种最大似然译码算法,根据接收到的含有噪声的码字,寻找出最有可能的原始数据序列。(2) 递推计算:根据接收到的码字和当前状态,计算下一时刻各个状态的路径度量,并记录每个状态的前驱状态。以上代码实现了一个简单的卷积码Viterbi译码算法,通过接收到的码字进行译码,并输出解码结果。(1) 初始化:将所有状态的路径度量初始化为一个很大的值,选择路径度量最小的状态作为起始状态。

2301_79331421的博客 827

What's New in the JMF 2.0 Reference Implementations

   Whats New in the JMF 2.0 Reference Implementations New Features in JMF 2.1.1 FCS Improved RTP API Added support for H.263/1998 (RFC 2429) - now can interoperate with Darwin based RTSP

CanFly的专栏 1639

基于Simulink的电机功率因数校正仿真

PF=SP​=视在功率有功功率​=cosϕ⋅Irms​I1​​(非正弦时)位移因数(cosϕ):基波电压电流相位差畸变因数(I1​/Irms​):谐波导致电流有效值增大本文带你完成了电机系统功率因数校正的Simulink仿真,实现了:✅ 理解了低功率因数的成因与危害✅ 搭建了无PFC、无源PFC、有源PFC三种对比模型✅ 掌握了Vienna整流器建模与dq解耦控制方法✅ 实现了PF与THD的自动计算与评估✅ 验证了有源PFC在PF、THD、稳定性上的全面优势。

amy_mhd的博客 154

Drag and Drop: New Data Transfer Capabilities in the JavaTM 2 Platform, Standard Edition (J2SETM), version 1.4

New Data Transfer CapabilitiesJohn ZukowskiNovember 2001 Sun is currently undergoing their third beta release of the JavaTM 2 Platform, Standard Edition (J2SETM), version 1.4. This latest release

CanFly的专栏 1582

1. 在 SAP ABAP 事物码 SEGW 里创建 SAP OData 项目

本文介绍如何在 SAP ABAP 事物码 SEGW 里创建 SEGW 项目,使用工具生成 Runtime 运行时需要的资源。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 5449

2026年软件测试职业院校技能大赛—ERP管理平台-采购入库模块Bug定位与查找

竞赛对接软件测试相关标准,以“ERP管理平台” 为被测系统,围绕软件测试领域的主流技术及工具,考查选手面 对实际问题的综合分析能力,对测试文档、测试用例的设计能力, 对单元测试、自动化测试、性能测试、接口测试等测试工具及方 法的掌握程度,检验选手团队协作能力、组织规划能力、方法运用能力等。

我是网络安全兼技能大赛工程师,专注网络安全技术学习与技能大赛实战!持续分享最新的技术文章,帮你少走弯路,一起在技术赛道上进步~ 203

Distributed Java Programming with RMI and CORBA

Distributed Java Programming with RMI and CORBAQusay H. MahmoudJanuary 2002 The Java Remote Method Invocation (RMI) mechanism and the Common Object Request Broker Architecture (CORBA) are the two

CanFly的专栏 1464

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

JINI NETWORK TECHNOLOGY DEFENDS THE ENVIRONMENT

JINITM NETWORK TECHNOLOGY DEFENDS THE ENVIRONMENT by Jon Byous November 8, 2001 -- Scientists at the U.S. Department of Energys Pacific Northwest National Laboratory (PNNL), in Richland,

CanFly的专栏 1335

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

NLEASHING J2EETM TECHNOLOGY'S POWER WITH EJBTM COMPONENTS

NLEASHING J2EETM TECHNOLOGYS POWER WITH EJBTM COMPONENTS by Michael Meloan March 20, 2001 -- The benefits of building ecommerce software applications from pretested, server-side JavaTM c

CanFly的专栏 1305

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Understanding the Manifest

Understanding the Manifest JAR files can support a wide range of functionality, including electronic signing, version control, package sealing, extensions, and others. What gives JAR files the abi

CanFly的专栏 1271

Lightweight UI Framework(有產生圓形Button的源碼)

Java AWT: Lightweight UI FrameworkThe ProblemOne of the issues with the 1.0 AWT is that creating new components requires creating subclasses of java.awt.Canvas or java.awt.Panel, which means that

CanFly的专栏 1251

GENERATING INTEGER RANDOM NUMBERS(幾種產生隨機數方法的效率分析)

GENERATING INTEGER RANDOM NUMBERSThere are many ways to generate random numbers with the base libraries found in the Java 2 SDK, Standard Edition. If you havent kept up to date with changes to the

CanFly的专栏 1246

CREATING ROUND SWING BUTTONS 2

CREATING ROUND SWING BUTTONSThis tip is about round Swing buttons. Actually, the information inthis tip applies to a button of any arbitrary shape but to keep thediscussion simple, were just going to

CanFly的专栏 1193

Adding Undo and Redo to a Text Component

 These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms Adding Undo and Redo to a Text Component JTextArea textarea = new JTextArea(); final UndoManager

CanFly的专栏 1167

Getting Listeners from JavaBeansTM

Getting Listeners from JavaBeansTM An Amendment to the JavaBeans Specification Hans Muller and Mark DavidsonPresently all of the state in an AWT component that can be written can also be read, e.g

CanFly的专栏 1155
上一篇: CREATING ROUND SWING BUTTONS 2
下一篇: JINI NETWORK TECHNOLOGY DEFENDS THE ENVIRONMENT
CanFly
博客等级 码龄25年 0粉丝 18原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值