I am making something that turns a string into an Integer if it is an Integer, or keeps it as a String if it is a String. I have that bit working fine, it is just when I try and check to see what the String is (if it is a string) I get Eclipse saying I have to insert != null because I am converting a boolean into a string. The thing is, if I click on it, it just makes more errors.
Here is my code:
import java.io.*; public class gplReader { //Class variables files f = new files(); //General Variables boolean nextIsInt; public gplReader(){ } public void startRead(String name) throws IOException{ try{ System.out.println("Reading File"); String[] aryLines = f.readFileData("gpl/" + name); System.out.println("Reading Data"); int i; for(i=0; i<aryLines.length; i++){ System.out.println("Printing line" + " " + (i+1) + " "); System.out.println(aryLines[i]); System.out.println("Interpreting line" + " " + (i+1) + ""); interpretGpl(aryLines[i]); } } finally { System.out.println("\nFinished Printing Lines\n"); } } public void interpretGpl(String aryLines){ String line = aryLines; String[] tempString = null; int[] tempInt = null; int i = 0; boolean isInt; boolean storeValue = false; try{ Integer.parseInt(line); System.out.println("Line is Integer" + "\n"); isInt = true; if(isInt != false){ tempInt[i] = Integer.parseInt(line); } } catch (Exception ex){ System.out.println("Line isn't an Integer" + "\n"); isInt = false; if(isInt != true){ tempString[i] = line; } } if(isInt != true){ if(tempString[i] != null){ ----if(tempString[0] = "printf"){---- } } } } }
The line of code surrounded by ---- is the bit that is throwing up errors.
Hope you can help.