Returning to Old position pointed by FileInputStream
<p>I'm reading data from a textfile. But after the code leaves from the main class to the Factory class, I want the empTextStreamIn to continue from where it left off. But for me its showing only the data related to the Salaried class. Kindly tell me what changes should I make in my Main class. My textfile has data related to all types of employees. </p>

<p>Assume all the necessary data.</p>

<p>Below are the code snippets</p>

<h1>Main.java</h1>

<pre><code>char valueInFirstColumn = 0;
while((valueInFirstColumn!=' ' || valueInFirstColumn!='\n') &amp;&amp; (empTextStreamIn.available()!=0))
        {
            employeeFileParser = empTextStreamIn.read();
            valueInFirstColumn = (char)employeeFileParser;
            Factory f = new Factory(empTextStreamIn,valueInFirstColumn);
        }
</code></pre>

<p>==============</p>

<h1>Factory.java</h1>

<pre><code>public Factory(FileInputStream empTextStreamIn, char valueInFirstColumn) throws IOException 
    {
        // TODO Auto-generated constructor stub
        //do
        //{
            if(valueInFirstColumn == '1')
            {
                Salaried slr = new Salaried(empTextStreamIn);
                slr.readData();
                slr.printData();
                //System.out.println(empTextStreamIn.read());
            }
            else if(valueInFirstColumn == '2')
            {
                Hourly hr = new Hourly(empTextStreamIn);
                hr.readData();
                hr.printData();
            }
            else if(valueInFirstColumn == '3')
            {
                Commissioned com = new Commissioned(empTextStreamIn);
                com.readData();
                com.printData();
            }
            else
            {
                System.out.println("Unkown Department");
            }
        }
</code></pre>

<p>=====================</p>

<p>Employee.java</p>

<pre><code>public Employee(FileInputStream empTextStreamIn) throws IOException
    {
        // TODO Auto-generated constructor stub
        do 
        {
            FileParser = empTextStreamIn.read();
            //System.out.println(FileParser);

            if(FileParser != -1)
            {
                parsed_text+=(char)FileParser;
            }

        } while(FileParser != -1);
        System.out.println(parsed_text);
        //FileParser = empTextStreamIn.read();
        //parsed_text+=(char)FileParser;
        //System.out.println(parsed_text);

        /*for (String everyLine : parsed_text.split("\\n"))
        {*/
                tokens1 = parsed_text.split("\\s+");
                //System.out.println(tokens1);
                /*String var1 = tokens1[0];
                empType = Integer.parseInt(var1);
                if(empType == 1)
                {*/
                    var1 = tokens1[1];
                    var2 = tokens1[2];
                    var3 = tokens1[3];
                    var4 = tokens1[4];
                /*}
        }*/



    }
    protected void readData()
    {
        EmpID = var1;
        DeptID = var2;

    }
    protected void printData()
    {
        System.out.print("Emp ID:"+EmpID+"  DeptID:"+DeptID);
    }
</code></pre>

<p>==============================</p>

<p>Salaried.java</p>

<pre><code>public class Salaried extends Employee
{
    double salary;  //Unique detail for Salaried class

    Salaried()
    {

    }

    Salaried(FileInputStream empTextStreamIn) throws IOException 
    {
        super(empTextStreamIn);
    }
    protected void readData()
    {
        super.readData();
        salary = Double.parseDouble(var3);
    }
    protected void printData()
    {
        super.printData();
        System.out.println("   Salary:"+salary);
    }

}
</code></pre>

<p>=====================================</p>

<p>Commissioned.java</p>

<pre><code>Commissioned(FileInputStream empTextStreamIn) throws IOException
    {
        super(empTextStreamIn);
    }
    protected void readData()
    {
        super.readData();
        sales = Double.parseDouble(var3);
    }
    protected void printData()
    {
        super.printData();
        System.out.println("   Sales:"+sales);
    }
</code></pre>

<p>===========================================</p>

<p>Hourly.txt</p>

<pre><code>Hourly(FileInputStream empFileInputStream) throws IOException
    {
        super(empFileInputStream);
    }
    protected void readData()
    {
        super.readData();
        hours = Double.parseDouble(var3);
        rate = Double.parseDouble(var4);
    }
    protected void printData()
    {
        super.printData();
        System.out.println("   Sales:"+hours+"   Rate:"+rate);
</code></pre>

<h1>        }</h1>

<p>Employee.txt</p>

<p>The first value is a code representing the employee type: 1 is salaried, 2 is hourly, and 3 is commission. 
The next column is the employee ID, 
the next the department ID of the employee. 
The next column varies depending on the employee type. 
-   For salaried employees it is their salary per annum. 
-   (For hourly employees it is the number of hours to be paid. Overtime (1.5) is paid for all time over 40 hours. 
-   Following the hours in column five is the rate of pay for the employee.)</p>

<pre><code>1 23938475683 1111 62000
2 30495848484 2222 40    21.5
3 40394833333 3333 30000
2 48584842283 2232 45    10
2 38485849494 2222 42.5  15
1 34345564433 1111 56000
3 98605050393 3333 12000
3 00033432738 3333 17000
</code></pre>

<p>======</p>

<p>Required Output</p>

<pre><code>Employee #23938475683  Dept# 1111    Salary:$62000
Employee #30495848484  Dept# 2222  Hours:40  Rate:$21.5
Employee #40394833333  Dept# 3333  Sales:$30000
Employee #48584842283  Dept# 2232  Hours:45  Rate:$10
Employee #38485849494  Dept# 2222  Hours:42.5  Rate:$15
Employee #34345564433  Dept# 1111  Salary:$56000
Employee #98605050393  Dept# 3333  Sales:$12000
Employee #00033432738  Dept# 3333  Sales:$17000
</code></pre>

<p>===============================</p>

<p>Obtained output</p>

<pre><code>Employee #:23938475683  Dept#:1111   Salary:62000.0
</code></pre>

<p>I'm not getting the other lines.</p>
