package filehandling;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.awt.event.ActionListener;
import javax.swing.*;

public class Filehandling extends JFrame{
 JTextArea ja;
 JButton jb;

  Container cont= getContentPane();
  ja=new JTextArea ();
  JPanel jp= new JPanel();
  jb=new JButton ("Save");


    public static void main(String[] args) {
        Filehandling fh= new Filehandling();
    class theHandler implements ActionListener 


        public void actionPerformed(ActionEvent e) {
           if (e.getSource()==jb)
               //Error is here

        public String function12(String man) throws Exception
    File f=new File("File.txt");
       FileOutputStream ob=new FileOutputStream(f.getName());
       byte [] bob= man.getBytes();
       return man;



function12 throws an Exception, but you never catch or throw it upwards when you call that method

I think that you need to use an loop to write the bytes from "man" into the output stream. Also try to flush the outputstream before you close it.

No need for a loop - the write method has a variant that takes an array of bytes (see the API doc).
flush() is more interesting. You would expect that FileOutputStream would flush as part of its close() method, but the API doc does not say anything on the subject. Although we all know that, in practice, close() is enough for a FileOutputStream, a properly paranoid programmer shoud call flush() just to be sure ;)

haider885: Looks like your function is not being called at all. The code doesnt reach there. Flow ends with creating the text area. Please check

haider885: When I said function, I meant the method function12.

It is called from the event handler, but I can't see the necessary call to addActionListener to make that work!

I want to copy TextArea text to a File... == for me (including properties from NativeOS, newline, tab, .....) is JTextArea.write