public synchronized boolean write(final File file) {

		if (file == null)
			throw new IllegalArgumentException("null input file");

		FileOutputStream out = null;
		try {
			out = new FileOutputStream(file);
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		if (out == null)
			return false;

		if (progressBar != null) {
			EventQueue.invokeLater(new Runnable() {
				public void run() {
					progressBar.setString("Writing......");
				}
			});
		}

		String text = null;
		try {
			text = page.getDocument().getText(0, page.getDocument().getLength());
		}
		catch (BadLocationException e) {
			e.printStackTrace();
			text = "Error in getting text from the document";
		}

		int clength = text.length();
		byte[] c = new byte[clength];
		c = text.getBytes();

		try {
			out.write(c, 0, clength);
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		finally {
			try {
				out.close();
			}
			catch (IOException e) {
				e.printStackTrace();
			}
		}

		if (progressBar != null)
			EventQueue.invokeLater(new Runnable() {
				public void run() {
					progressBar.setString("Done");
				}
			});

		return true;

	}