java - Returning NULL from string with appened chars -
the string dexversion returns null
i tried many things taking string , appending readdata[] char , worked fine , tried see if char vs. character results inconclusive
import java.io.*; import java.net.*; import java.lang.*; import java.util.*; class main { public static void main(string args[]) { string version = new string("1.0 (alpha)"); main main = new main(); datahandling data = new datahandling(); boolean doneprocessing = false; int x = 0,y = 0; string dexversion = new string("v:"); string pokemon[][] = new string[700][10]; system.out.println(":"); system.out.println("pokeutility:main_thread_started_in_static_method_main"); system.out.println("pokeutility:starting_version=" + version); system.out.println("pokeutility:downloading_pokedex_data"); data.download(); system.out.println("pokeutility:reading_pokedex_data"); char readdata[] = data.read(); system.out.println("pokeutility:processing_pokedex_data"); while (doneprocessing = false) { if ((readdata[x]) == '{') { x++; while ((readdata[x]) != '}') { dexversion += readdata[x]; x++; } } // if ((readdata[x]) == '[') { // x++; // while ((readdata[x]) != ']') { // dexversion += readdata[x]; // x++; // } // } if ((readdata[x]) == '%') doneprocessing = true; x++; } system.out.println(dexversion + "."); } } class datahandling { public void download() { bufferedinputstream dfile; fileoutputstream wfile; try { dfile = new bufferedinputstream(new url("http://www.harry.technology/pokedex").openstream()); wfile = new fileoutputstream("pokedex"); int x = 0,y = 0; while ((x = dfile.read()) != -1) { wfile.write(x); } wfile.close(); dfile.close(); } catch (ioexception e) { system.out.println("pokeutility:error_" + e); system.exit(0); } } public char[] read() { int x = 0,y = 0; char input[] = new char[2000]; string output = new string(""); try { filereader file = new filereader("pokedex"); while ((x = file.read()) != -1) { input[y] = convert(x); y++; } file.close(); } catch (ioexception e) { system.out.println("pokeutility:error_" + e); system.exit(0); } return input; } public char convert(int a) { switch (a) { ascii switch statement (left out because of length) } } }
here file "pokedex":
{1.0} [001,bulbasaur] %
you can see on server visiting: http://www.harry.technology/pokedex
Comments
Post a Comment