package filehandling;
import java.awt.event.ActionEvent;
import java.io.*;
import java.awt.*;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Filehandling extends JFrame{
JTextArea ja;
JButton jb;
Filehandling()
{
setBounds(400,400,400,400);
setTitle("azeem");
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cont= getContentPane();
ja=new JTextArea ();
cont.add(ja,BorderLayout.CENTER);
JPanel jp= new JPanel();
jb=new JButton ("Save");
jp.add(jb);
cont.add(jp,BorderLayout.SOUTH);
setVisible(true);
}
public static void main(String[] args) {
Filehandling fh= new Filehandling();
}
class theHandler implements ActionListener
{
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource()==jb)
{
//Error is here
function12(ja.getText());
}
}
public String function12(String man) throws Exception
{
File f=new File("File.txt");
FileOutputStream ob=new FileOutputStream(f.getName());
byte [] bob= man.getBytes();
ob.write(bob);
ob.close();
return man;
}
}
}
haider885
0
Newbie Poster
Recommended Answers
Jump to Postfunction12 throws an Exception, but you never catch or throw it upwards when you call that method
Jump to PostI want to copy TextArea text to a File... == for me (including properties from NativeOS, newline, tab, .....) is JTextArea.write
All 7 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
newcoder310
0
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
newcoder310
0
Junior Poster in Training
newcoder310
0
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
mKorbel
274
Veteran Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.