• 大小: 0.04M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-01-17
  • 语言: Java
  • 标签: 通讯  串口  

资源简介

简单的实现了一般的串口通讯

资源截图

代码片段和文件信息

package serialException;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 负责将传入的Exception中的错误信息提取出来并转换成字符串;
 * @author zhong
 *
 */
public class ExceptionWriter {

    /**
     * 将Exception中的错误信息封装到字符串中并返回该字符串
     * @param e 包含错误的Exception
     * @return 错误信息字符串
     */
    public static String getErrorInfoFromException(Exception e) { 
            
            StringWriter sw = null;
            PrintWriter pw = null;
            
            try {  
                sw = new StringWriter();  
                pw = new PrintWriter(sw);  
                e.printStackTrace(pw);  
                return “\r\n“ + sw.toString() + “\r\n“;  
                
            } catch (Exception e2) {  
                return “出错啦

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        409  2017-09-06 14:05  serialMonitor\.classpath

     文件        389  2017-09-06 14:04  serialMonitor\.project

     文件        598  2017-09-06 14:04  serialMonitor\.settings\org.eclipse.jdt.core.prefs

     文件       1561  2017-09-06 14:08  serialMonitor\bin\serialException\ExceptionWriter.class

     文件        489  2017-09-06 14:20  serialMonitor\bin\serialException\NoSuchPort.class

     文件        501  2017-09-06 14:15  serialMonitor\bin\serialException\NotASerialPort.class

     文件        468  2017-09-06 14:17  serialMonitor\bin\serialException\PortInUse.class

     文件        540  2017-09-06 14:19  serialMonitor\bin\serialException\ReadDataFromSerialPortFailure.class

     文件        531  2017-09-06 14:18  serialMonitor\bin\serialException\SendDataToSerialPortFailure.class

     文件        555  2017-09-06 14:20  serialMonitor\bin\serialException\SerialPortInputStreamCloseFailure.class

     文件        561  2017-09-06 14:19  serialMonitor\bin\serialException\SerialPortOutputStreamCloseFailure.class

     文件        558  2017-09-06 14:07  serialMonitor\bin\serialException\SerialPortParameterFailure.class

     文件        492  2017-09-06 14:25  serialMonitor\bin\serialException\TooManyListeners.class

     文件        674  2017-09-06 14:26  serialMonitor\bin\serialPort\Client$1.class

     文件       1000  2017-09-06 14:26  serialMonitor\bin\serialPort\Client$KeyMonitor.class

     文件       1245  2017-09-06 14:26  serialMonitor\bin\serialPort\Client$RepaintThread.class

     文件       3408  2017-09-06 14:26  serialMonitor\bin\serialPort\Client.class

     文件       4074  2017-09-06 14:27  serialMonitor\bin\serialPort\computer.png

     文件        877  2017-09-07 18:43  serialMonitor\bin\serialPort\DataView$1.class

     文件       2314  2017-09-07 18:43  serialMonitor\bin\serialPort\DataView$2.class

     文件       2495  2017-09-07 18:43  serialMonitor\bin\serialPort\DataView$RepaintThread.class

     文件       3227  2017-09-07 18:43  serialMonitor\bin\serialPort\DataView$SerialListener.class

     文件       6755  2017-09-07 18:43  serialMonitor\bin\serialPort\DataView.class

     文件       4846  2017-09-06 14:25  serialMonitor\bin\serialPort\SerialTool.class

     文件       1278  2017-09-06 14:08  serialMonitor\src\serialException\ExceptionWriter.java

     文件        297  2017-09-06 14:20  serialMonitor\src\serialException\NoSuchPort.java

     文件        301  2017-09-06 14:15  serialMonitor\src\serialException\NotASerialPort.java

     文件        279  2017-09-06 14:17  serialMonitor\src\serialException\PortInUse.java

     文件        329  2017-09-06 14:19  serialMonitor\src\serialException\ReadDataFromSerialPortFailure.java

     文件        321  2017-09-06 14:18  serialMonitor\src\serialException\SendDataToSerialPortFailure.java

............此处省略19个文件信息

评论

共有 条评论