⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memmapjavaclient.java

📁 150个非常经典的例子 全部代码全部在JDK中调试成功
💻 JAVA
字号:
package com.stanley.memmap;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MemMapJavaClient extends JFrame implements MemMapFileObserver{  protected JButton btnClose;  protected JTextArea textArea;  protected MemMapProxy proxy;  public static final String fileMappingObjName = "Mem_Map_File-{70122C30-0239-4f98-9D21-36885C8A8121}";  //Construct the frame  public MemMapJavaClient() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      init();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void init() throws Exception  {    JPanel contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(new BorderLayout());    textArea = new JTextArea();    contentPane.add(textArea, BorderLayout.CENTER);    btnClose = new JButton("Close");    btnClose.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	destroy();      }    });    JPanel panelBtn = new JPanel();    panelBtn.add(btnClose);    contentPane.add(panelBtn, BorderLayout.SOUTH);    proxy = new MemMapProxy(this);    setSize(new Dimension(400, 300));    setTitle("Test Memory Map File - Java Client");  }  private void destroy() {    proxy.destroy();    System.exit(0);  }  public void onDataReady() {    int mapFilePtr = MemMapFile.openFileMapping(MemMapFile.FILE_MAP_READ, false,        fileMappingObjName);    if(mapFilePtr != 0) {      int viewPtr = MemMapFile.mapViewOfFile(mapFilePtr,	  MemMapFile.FILE_MAP_READ, 0, 0, 0);      if(viewPtr != 0) {	String content = MemMapFile.readFromMem(viewPtr);	textArea.setText(content);	MemMapFile.unmapViewOfFile(viewPtr);      }      MemMapFile.closeHandle(mapFilePtr);    }  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      destroy();    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -