Hi,
I have this peace of Java code and I would like to know how to change the file location in the code. (only a filename (test.txt) is in the code and I would like to add a path (c:\test.txt).
Code:import java.io.*; import java.util.*; class StackDemoUsingArrays{ static String [] myString = new String[3]; static int count = 0; public static void main (String args[]) throws Exception { BufferedReader br = new BufferedReader (new InputStreamReader(new FileInputStream(new File("test.txt")))); // <-- I want to change this String str = ""; while((str = br.readLine()) != null){ push(str.trim()); } System.out.println(pop()); } public static String pop(){ if(count<=0) { System.out.println("Cannot pop an empty stack"); System.exit(0); } return myString[-- count]; } public static void push(Object o){ if(count == myString.length){ String [] myString1 = new String[myString.length*2]; System.arraycopy((Object)myString,0,(Object)myString1,0,myString.length); myString = myString1; } myString[count] = o.toString(); count++; } }


Reply With Quote