Witam,
Mianowicie kod:
private static boolean scanCDP(DataInputStream dis, PrintStream ps,
String sCont, String sPath) throws Exception {
// Scan .cdp file function itself
int iVal, iFilePtr = 0, iLength, iFileEnd, iBlockEnd, iRecEnd, iFieldEnd;
String sVal, skuid, sField, sKind, sClass, sRegion, sUName, sType,
sAuth, sEra, sAssFName, sName;
byte bVal;
byte[] baVal = new byte[256];
boolean bAssets = false;
iFilePtr += dis.read(baVal, 0, 4); // Read file ID
sVal = new String(baVal, 0, 4);
if (sVal.compareTo("ACS$") != 0) {
// "ACS$" authenticates CDP files
return false;
}
iFilePtr += dis.skipBytes(8); // These bytes are not used
iLength = IntBitsRotation(dis.readInt()); // Read file length
iFilePtr += 4;
if (iLength == 0) {
return false;
}
inFILES++;
iFileEnd = iFilePtr + iLength; // EOF pointer
while (iFilePtr < iFileEnd && !bAssets) {
// Read simultaneous blocks
iLength = IntBitsRotation(dis.readInt()); // Block length
iFilePtr += 4;
iBlockEnd = iFilePtr + iLength; // next block pointer
bVal = dis.readByte(); // This byte is not used
iFilePtr++;
iVal = (int)bVal; // Block name length
iFilePtr += dis.read(baVal, 0, iVal); // Block name
sVal = new String(baVal, 0, iVal - 1);
if (sVal.equalsIgnoreCase("assets")) {
// assets block contains kuids and their description
bAssets = true; // Only asset block is processed
dis.readByte(); // This byte is not used
iFilePtr++;
while (iFilePtr < iBlockEnd) {
// Read kuids sections
iLength = IntBitsRotation(dis.readInt()); // kuid section length
iFilePtr += 4;
iRecEnd = iFilePtr + iLength; // next kuid section pointer
bVal = dis.readByte(); // kuid string length
iFilePtr++;
iVal = (int)bVal;
iFilePtr += dis.read(baVal, 0, iVal); // kuid
dis.readByte(); // This byte is not used
iFilePtr++;
skuid = new String(baVal, 0, iVal - 1);
sKind = "";
sType = "";
sClass = "";
sRegion = "";
sEra = "";
sAuth = "";
sUName = "";
sName = "";
sAssFName = "";
while (iFilePtr < iRecEnd) {
// scans asset fields
iLength = IntBitsRotation(dis.readInt()); // Field length
iFilePtr += 4;
iFieldEnd = iFilePtr + iLength; // next field pointer
bVal = dis.readByte(); // field name length
iFilePtr++;
iVal = (int)bVal;
iFilePtr += dis.read(baVal, 0, iVal); // field name
sField = new String(baVal, 0, iVal - 1);
bVal = dis.readByte(); // field value type
iFilePtr ++;
if (bVal == 3 && (iFieldEnd - iFilePtr) > 1
&& (iFieldEnd - iFilePtr) < 256) {
// field value type is string
iLength = dis.read(baVal, 0, iFieldEnd - iFilePtr); // field value
iFilePtr += iLength;
sVal = new String(baVal, 0, iLength - 1);
sVal = ClearString(sVal); // clear bad chars
if (sField.equalsIgnoreCase("kind")) {
sKind = sVal;
} else if (sField.equalsIgnoreCase("type")) {
sType = sVal;
} else if (sField.equalsIgnoreCase("category-class")) {
sClass = sVal;
} else if (sField.matches("category-region-\\d+")) { //tu błąd
sRegion += (sRegion.isEmpty() ? "" : ",")+sVal;
} else if (sField.matches("category-era-\\d+")) { // tu błąd
sEra += (sEra.isEmpty() ? "" : ",")+sVal;
} else if (sField.equalsIgnoreCase("author")) {
sAuth = sVal;
} else if (sField.equalsIgnoreCase("username")) {
sUName = sVal;
} else if (sField.equalsIgnoreCase("asset-filename")) {
sAssFName = sVal;
} else if (sField.equalsIgnoreCase("name")) {
sName = sVal;
}
} else if (bVal == 1 && (iFieldEnd - iFilePtr) >= 4) {
// field value type is integer
iLength = IntBitsRotation(dis.readInt());
iFilePtr += 4;
if (sField.matches("category-era-\\d+")) { // tu błąd
sEra += (sEra.isEmpty() ? "" : ",")+iLength+"s";
}
}
iFilePtr += dis.skipBytes(iFieldEnd - iFilePtr); // goto next field
}
// end of kuid, print fields values
ps.println(skuid+"~!"+sKind+"~!"+sUName+"~!"+sRegion+"~!"+sEra+"~!"+sAuth);
inKUID++; // one more kuid processed
}
} else {
iFilePtr += dis.skipBytes(iBlockEnd - iFilePtr); // goto next block
}
}
return true;
}
Skompilowany w
http://www.onlinecompiler.net/javapowoduje błędy
Compiler Output:
4sfShx9L.java:146: illegal escape character
} else if (sField.matches("category-region-\d+")) {
^
4sfShx9L.java:148: illegal escape character
} else if (sField.matches("category-era-\d+")) {
^
4sfShx9L.java:163: illegal escape character
if (sField.matches("category-era-\d+")) {
^
3 errors
(Kod źródłowy nie jest oddany w całości więc miejsca, gdzie się one znajdują oznaczyłem komentarzem)
Nie znam Javy, a moje poprawki wynikały z domysłów, więc prosiłbym o konkretną instrukcję GDZIE, CO I JAK. Dziękuję za wyrozumiałość :-)