Q:

Issues writing doubles to files, writing nothing

I seem to be missing something when it comes to writing doubles to text files, when I check the file, just blank space is present. When I read from the file and print with System.out.println(); it just prints nothing... What's going wrong here? Do I need to do some converting?
import java.io.*;
import javax.swing.JOptionPane;

public class ReadCalcAveragePrint  {

    double firstNum;
    double secondNum;
    double average;

    public void readFile() {

        try {
            File f = new File("numbers.txt");
            BufferedReader br = new BufferedReader(new FileReader(f));
            String one = br.readLine();
            String two = br.readLine();
            firstNum = Double.parseDouble(one);
            secondNum = Double.parseDouble(two);

            average = (firstNum + secondNum) / 2;
            JOptionPane.showMessageDialog(null, average, "title", JOptionPane.PLAIN_MESSAGE);

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }

    }

    public void writeFile() {
        try {
            File f = new File("result.txt");
            FileOutputStream fos = new FileOutputStream(f);
            DataOutputStream dos = new DataOutputStream(fos);
            dos.writeDouble(average);
            dos.flush();
            fos.close();
            System.out.println("Printed.");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);

        }
    }

    public void readResult() {

        try {
            File f = new File("result.txt");
            BufferedReader br = new BufferedReader(new FileReader(f));
            String one = br.readLine();
            System.out.println(one);

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }

    }

    public static void main(String[] args) {

        new ReadCalcAveragePrint().readFile();
        new ReadCalcAveragePrint().writeFile();
        new ReadCalcAveragePrint().readResult();
    }
}

A:

In the main you are creating 3 different objects, only the first is going to contain the numbers you read from the file.
You should just create and reuse one object:
public static void main(String[] args) {
    ReadCalcAveragePrint obj = new ReadCalcAveragePrint();
    obj.readFile();
    obj.writeFile();
    obj.readResult();
}

Also you are writing the result file using DataOutputStream which is meant to write the data in binary form. If you just want to save the result as text you should use FileWriter instead:
File f = new File("result.txt");
FileWriter fw = new FileWriter(f);
fw.write(String.valueOf(average));
fw.close();

