gpt4 book ai didi

java - 如何从保留字符列表中删除最后一个字符?

转载 作者:行者123 更新时间:2023-12-02 00:23:19 24 4
gpt4 key购买 nike

如何从偶数/奇数条件中删除最后一个 |

示例:

import java.io.*;
import java.net.Socket;

public class Test {

public static String _noManualTraceIt = "0008e07cd8ec6cfdb900283508004500004a7d8d400080060000c0a80087c0a800c6c6931388956304704eebd50c5018ffff82da0000674500000504000000000000030000000000000000000000060000000000ff210000";
public static void main(String[] args) throws IOException {
System.out.println( wireShirk(_noManualTraceIt) );
}

public static byte[] wireShirk(String bytes) throws IOException {
String temp = "";
String replaceIfOnLastFound = "||&|\r\n|\n\r|etc|etc";

int _i = 0;
do {
temp += bytes.charAt(_i);
if(_i%2 ==0) {
} else {
temp += "|";
}
System.out.println(bytes.length() + " " + _i + " " + two.charAt(_i) + " " + temp);
_i++;
} while(_i<bytes.length());

bytes = temp; // << replaceIfOnLastFound any of those characters
// | or & or \r\n or etc etc from that variable


String byteArrayStr[] = bytes.split("\\|");
byte bytesArray[] = new byte[byteArrayStr.length];
for (int i = 0; i < byteArrayStr.length; ++i) {
bytesArray[i] = (byte) (Integer.parseInt(byteArrayStr[i], 16));
}
return bytesArray;
}

}

输出:

176 175 0 00|08|e0|7c|d8|ec|6c|fd|b9|00|28|35|08|00|45|00|00|4a|7d|8d|40|00|80|06|00|00|c0|a8|00|87|c0|a8|00|c6|c6|93|13|88|95|63|04|70|4e|eb|d5|0c|50|18|ff|ff|82|da|00|00|67|45|00|00|05|04|00|00|00|00|00|00|03|00|00|00|00|00|00|00|00|00|00|00|06|00|00|00|00|00|ff|21|00|00|

最佳答案

在循环内添加 if 语句..

} else {
if(i < bytes.length - 1){
temp += "|";
}
}

关于java - 如何从保留字符列表中删除最后一个字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10518707/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com