i was trying to create a program that would have a button that when you clicked it it would ask for the input of a name followed by the input of an url and then create a file with both of those it would also store the name in a list of all the names
now inorder to add a name to the list i was using
now my problem is it is supposed to be on the internet and that gives me an error of some kind and the button won't even show up on the webpage.
so i was trying to replace
with
but unfortunately BufferedReader doesn't have an available() method
used right aftter the declaration
if anyone could tell me the best way around this it would be appreciated and it may be an unrelated problem but why the button won't show up
now inorder to add a name to the list i was using
| Code: |
| ArrayList PriorLines = new ArrayList();
FileOutputStream out; PrintStream p; try { FileInputStream fstream = new FileInputStream("Items.txt"); DataInputStream in = new DataInputStream(fstream); while (in.available() !=0) { PriorLines.add(in.readLine()); } in.close(); out = new FileOutputStream("Items.txt"); p = new PrintStream( out ); for(int i =0; i<PriorLines.size(); i++) { p.println(PriorLines.get(i)); } p.println(item); p.close(); } catch (Exception e) { System.err.println("File error"); } |
now my problem is it is supposed to be on the internet and that gives me an error of some kind and the button won't even show up on the webpage.
so i was trying to replace
| Code: |
| FileInputStream fstream = new FileInputStream("Items.txt");
DataInputStream in = new DataInputStream(fstream); |
with
| Code: |
| BufferedReader in = new BufferedReader(new InputStreamReader(
new FileInputStream(new File("files/Items.txt")))); |
but unfortunately BufferedReader doesn't have an available() method
used right aftter the declaration
| Code: |
| while (in.available() !=0) |
if anyone could tell me the best way around this it would be appreciated and it may be an unrelated problem but why the button won't show up
