그래서 String []을 만들고 코드의이 섹션에서 확인중인 코드 행을 놓칩니다. * 참고 사항 :이 방법이 가장 적합한 방법인지는 알고 있지만 이는 단지 개념 증명 일 뿐이며 나중에 변경 될 것입니다.코드의 한 부분에서 줄을 생략했지만 다른 줄을 표시하는 배열
다음 코드에서 그러나public class DummyBukkitClass extends JavaPlugin {
@Override
// Some Profound code can be found here
}
@Override
// The Profound code is now ending =(
}
}
그것이 내가 너무 그것을 필요 반환 :이 다음 반환 이제
private void checkMethods() {
for (int i = 0; i < array.length; i++) {
String s = array[i];
System.out.println(s);
if(array[i].contains("onEnable()")) {
System.out.println("enable");
array[i] = MethodUpdate.onEnable;
}
else if (isOnDisable(s)) {
System.out.println("disable");
array[i] = MethodUpdate.onDisable;
}
else if (isOverride(s)) {
if (checkNextLine(array[i++])) {
array[i] = "";
}
}
}
}
: 어쨌든, 여기 나에게 문제를 제공하는 코드는
public void updateFile(File file) throws IOException {
BufferedReader br = null;
pw = null;
try {
br = new BufferedReader(new FileReader("classes/DummyBukkitClass.java"));
file.getParentFile().mkdirs();
pw = new PrintWriter(file);
String line;
int index = 0;
while ((line = br.readLine()) != null) {
array[index] = line;
index++;
}
} finally {
checkMethods();
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
pw.println(array[i]);
}
br.close();
pw.flush();
pw.close();
}
}
이제 반환됩니다.
public class DummyBukkitClass extends JavaPlugin {
@Override
public void onEnable() {
// Some Profound code can be found here
}
@Override
public void onDisable() {
// The Profound code is now ending =(
}
}
저는 왜 그 중 하나가 2 라인을 생략하고있는 바로 그 이유를 설명 할 수 없습니다. 그들은 추가 과정에서 모두 인쇄 할 수 있습니다. checkMethods()가 호출되기 전에 인쇄 할 수 있습니다. 도와주세요!
고마워요!
편집 :
이 else if (isOverride(array[i])) {
if (checkNextLine(array[i+1])) { //HERE
array[i] = "";
}
}
그 뒤에 이유는 이것이다 : checkMethods에서
else if (isOverride(array[i])) {
if (checkNextLine(array[i++])) {
array[i] = "";
}
}
(일) :
내가 변경하는 데 필요한 문제를 해결하기 위해 나는이 증가했다 크기 'i'를 사용하면 다시 설정하지 않고 'i'를 다시 사용합니다. 'i + 1'은 새로운 값을 i로 설정하지 않기 때문에 해결됩니다.
당신이 그것을 닫기 전에'br.flush을()'싶지? 또한 코드가 다소 불완전하기 때문에 finally 블록 (예 : try/catch 비트) 전에 어떤 일이 발생했는지 이해할 수 없습니다. – ha9u63ar
@hagubear 편집 : 아니요. 플러시 할 수 없습니다. P – user1767369
@ user1768369 아직 try/catch 코드가 더 필요합니다 ... 마침내 실제로는별로 알려주지 않습니다. – ha9u63ar