here is what i have so far. the problem i am faceing is how do i find the number of elemets in the file so i can initialze the queue. Your suggestions will b most appritated.
class FileHandler {
BufferedReader data;
DataInputStream in;
public FileHandler(String fileName) {
try {
data = new BufferedReader(new FileReader(fileName));
} catch (IOException e) {
e.printStackTrace();
}
}
public FiFo fileToLines() {
///////////////////here is where i need ur help whats teh string size////////////////////
private FiFo lines=new FiFo(data.)
String line = "";
try {
while ((line = data.readLine()) != null) {
lines.add(line);
}
} catch (IOException e) {
e.printStackTrace();
}*/
return lines;
}
public void closeFile() {
try {
data.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public class FiFo {
private int index;
private String[] queue;
public FiFo(int size)
{
queue=new String[size];
index=0;
}
public void add(String element)
{
queue[index]=element;
index++;
}
public void remove()
{
int temp=0;
while(temp!=index)
{
queue[temp]=queue[temp+1];
temp++;
}
index--;
}
public String get()
{
return queue[0];
}
public int size()
{
return index;
}
public void printQueue()
{
for (int i=0;i<=index;i++)
System.out.println(queue[i]);
}