我有个问题。
您有字符串 "1;2;3;4;5" 并且想要一一显示它们。结果是:
1
2
3
4
5
到目前为止,我已经对此进行了编程。
package deel_3;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
public class deel_3punt0
{
public static void main(String[] args) {
try{
//bijschrijven van banlist
//FileWriter fwriter = new FileWriter("File2", true);
//PrintWriter outputFile = new PrintWriter(fwriter);
//lezen van de huidige lijst
BufferedReader br = new BufferedReader(new FileReader("C:\\JavaStuff\\testyeah.txt"));
BufferedReader br2 = new BufferedReader(new FileReader("C:\\Users\\Tim\\workspace\\deel_2\\n4d2 2.3.txt"));
String IPF3_1 = null;
while((IPF3_1 = br.readLine()) != null){
//input splitten
String arrIPF3_1 [] = IPF3_1.split(";");
System.out.println(arrIPF3_1[1]);
//het codewoord vinden
String StrIPF3_1 = arrIPF3_1[1];
//de lengte van het codewoord halen
int mim = StrIPF3_1.length();
System.out.println(mim);
//bits losmaken
String arrayinput311[]= StrIPF3_1.split("");
System.out.println(arrayinput311[2]);
//eerste whileloop goed
String IPF3_1_2 = null;
while((IPF3_1_2 = br2.readLine()) != null){
System.out.println(IPF3_1_2);
//input van banlist splitten
String arrIPF3_1_2 [] = IPF3_1_2.split(";");
//het woord voor de afstand vinden
String StrIPF3_1_2 = arrIPF3_1_2[1];
System.out.println(StrIPF3_1_2);
//de lengte van het woord vinden
int mimban = StrIPF3_1.length();
System.out.println(mimban);
//bits vinden
String arrayinput312[] = StrIPF3_1_2.split("");
System.out.println(arrayinput312[1]);
int loop314 = 0;
StringBuffer BFSTRING = new StringBuffer("");
while(loop314<mim-1){
//bits omzetten naar getallen voor de IF statement
int getalIPF31 = Integer.parseInt(arrayinput312[loop314]);
int getalIPF312 = Integer.parseInt(arrayinput311[loop314]);
if(getalIPF31==getalIPF312){
BFSTRING.append(0);
}
else{
BFSTRING.append(1);
}
loop314 = loop314 +1;
}
double macht = 0;
int loop315 = 0;
double decimalewaarde = 0;
String Bfstring = BFSTRING.toString();
String Bfstring2 [] = Bfstring.split("");
while(loop315<mim-1){
int bit_3=Integer.parseInt(Bfstring2[loop315]);
if(bit_3==1){
decimalewaarde = (decimalewaarde + Math.pow(2, macht));
}
else{
}
loop315 = loop315 +1;
}
System.out.println(decimalewaarde);
FileWriter fwriter = new FileWriter("nieuwebanwoorden.txt", true);
PrintWriter outputFile = new PrintWriter(fwriter);
outputFile.println(decimalewaarde);
outputFile.close();
}
}
}
catch(Exception e){
System.out.println("error");
}
}
}
我的线路有问题
int getalIPF31 = Integer.parseInt(arrayinput312[loop314]);
int getalIPF312 = Integer.parseInt(arrayinput311[loop314]);
我用来System.out.println()
检查错误在哪里。