<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ``` /** * @author 張躍帥 * @Description: 獲取網絡速度-工具 * @date 2020/08/12 */ @Slf4j public class NetworkUtil { /** * 網速測速時間2s */ private static final int SLEEP_SECONDS = 2; /** * 獲取網絡上下行速率 * 格式{"UP": "123KB/S, "DOWN": "345KB/S"} */ public static Dict getNetworkUpRate() { // 創建map Dict dictMap = Dict.create(); // 變量-過程 Process pro = null; // 獲取運行時 Runtime r = Runtime.getRuntime(); // 變量-緩沖區讀取 BufferedReader input = null; try { // 獲取當前的操作系統 boolean isWindows = SystemUtil.getOsInfo().isWindows(); // windows命令 String command = isWindows ? "netstat -e" : "ifconfig"; // 執行命令 pro = r.exec(command); // 創建緩沖讀卡器 input = new BufferedReader(new InputStreamReader(pro.getInputStream())); // 聯機讀取 long[] result1 = readInLine(input, isWindows); // 等待 Thread.sleep(SLEEP_SECONDS * 1000); // 銷毀 pro.destroy(); // 關閉 input.close(); // 執行命令 pro = r.exec(command); // 創建緩沖讀卡器 input = new BufferedReader(new InputStreamReader(pro.getInputStream())); // 聯機讀取 long[] result2 = readInLine(input, isWindows); // 可讀文件大小 String upSpeed = FileUtil.readableFileSize(Convert.toLong(NumberUtil.div(NumberUtil.sub(result2[0], result1[0]), SLEEP_SECONDS))); String downSpeed = FileUtil.readableFileSize(Convert.toLong(NumberUtil.div(NumberUtil.sub(result2[1], result1[1]), SLEEP_SECONDS))); // 添加 dictMap.put("up", upSpeed + (upSpeed.endsWith("B") ? "/S" : "B/S")); dictMap.put("down", downSpeed + (downSpeed.endsWith("B") ? "/S" : "B/S")); } catch (Exception e) { log.info(">>> 獲取網絡測速失敗", e.getMessage()); } finally { // 判斷 if (input != null) { try { // 關閉 input.close(); } catch (IOException e) { log.info(">>> 獲取網絡測速失敗", e.getMessage()); } } // 使用Optional是用來設置默認值的,杜絕null的出現 Optional.ofNullable(pro).ifPresent(Process::destroy); } // 返回 return dictMap; } /** * 格式數字 */ @SuppressWarnings("all") private static String formatNumber(double f) { return new Formatter().format("%.2f", f).toString(); } /** * 聯機讀取 */ private static long[] readInLine(BufferedReader input, boolean isWindows) { // 變量數組 long[] arr = new long[2]; // 變量-字符串標記器 StringTokenizer tokenStat; try { // 判斷-操作系統 if (isWindows) { // 獲取windows環境下的網口上下行速率 input.readLine(); input.readLine(); input.readLine(); input.readLine(); // 創建-字符串標記器 tokenStat = new StringTokenizer(input.readLine()); // 下一個令牌 tokenStat.nextToken(); // 參數轉換 arr[0] = Long.parseLong(tokenStat.nextToken()); arr[1] = Long.parseLong(tokenStat.nextToken()); } else { // 獲取linux環境下的網口上下行速率 long rx = 0, tx = 0; // 變量 String line = null; // RX packets:4171603 errors:0 dropped:0 overruns:0 frame:0 // TX packets:4171603 errors:0 dropped:0 overruns:0 carrier:0 // 遍歷 while ((line = input.readLine()) != null) { // 判斷 if (line.contains("RX packets")) { // 拼接 rx += Long.parseLong(line.substring(line.indexOf("RX packets") + 11, line.indexOf(" ", line.indexOf("RX packets") + 11))); } else if (line.contains("TX packets")) { // 拼接 tx += Long.parseLong(line.substring(line.indexOf("TX packets") + 11, line.indexOf(" ", line.indexOf("TX packets") + 11))); } } // 賦值 arr[0] = rx; arr[1] = tx; } } catch (Exception e) { log.info(">>> 獲取網絡測速失敗", e.getMessage()); } // 返回 return arr; } }
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看