Home Answers Viewqa Applet Creating a log in a text file

 
 


hersh
Creating a log in a text file
1 Answer(s)      4 years and 8 months ago
Posted in : Applet

View Answers

October 3, 2008 at 4:11 PM


Hi,


import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;
import java.net.*;

public class AppletTextDemo extends Applet{
JButton write = new JButton("WriteToFile");
Label label1 = new Label("Enter the file name:");
TextField text = new TextField(20);
Label label2 = new Label("Write your text:");
TextArea area = new TextArea(10,20);
public void init(){
add(label1);
label1.setBackground(Color.lightGray);
add(text);
add(label2);
label2.setBackground(Color.lightGray);
add(area);
add(write,BorderLayout.CENTER);
write.addActionListener(new ActionListener (){
public void actionPerformed(ActionEvent e){
new WriteText();
}
});
}
public class WriteText {
WriteText(){
try {
String str = text.getText();
if(str.equals("")){
JOptionPane.showMessageDialog(null,"Please enter the file name!");
text.requestFocus();
}
else{
File f = new File(str);
if(f.exists()){
BufferedWriter out = new BufferedWriter(new FileWriter(f,true));
if(area.getText().equals("")){
JOptionPane.showMessageDialog(null,"Please enter your text!");
area.requestFocus();
}
else{
out.write(area.getText());
if(f.canWrite()){
JOptionPane.showMessageDialog(null,"Text is written in "+str);
text.setText("");
area.setText("");
text.requestFocus();
}
else{
JOptionPane.showMessageDialog(null,"Text isn't written in "+str);
}
out.close();
}
}
else{
JOptionPane.showMessageDialog(null,"File not found!");
text.setText("");
text.requestFocus();
}
}
}
catch(Exception x){
x.printStackTrace();
}
}
}
}

----------------------
<HTML>
<BODY>
<div align = "center">
<APPLET CODE = "AppletTextDemo.class" WIDTH = "500" HEIGHT = "400"></APPLET>
</div>
</BODY>
</HTML>

------------------------------------


Visit for more information.

http://www.roseindia.net/java/

Thanks









Related Pages:
Creating a log in a text file - Applet
Creating a log in a text file  Hey there, I have created an applet... as an application. Therefore i have added it onto a frame. I need to create a text file... time it is run. I have figured of a way of writing the time to a text file using
a jsp code for creating a text file
a jsp code for creating a text file  Hello,i need jsp code for creating a new text file for each user, when they login in to the website for creating a new data file. So i need a jsp code for following options. when user login
How could we get log file as simple text format
How could we get log file as simple text format  Above given javaerrorlog creates the log file in xml code how could we get it in simple text Manmohan
Creating an executable jar file
Creating an executable jar file  When I try to create jar.exe through CMD, the manifest file created doesn't contain Main-Class attribute, even though it is included in text file used during creation of jar file
Writing Log Records to a Log File
Writing Log Records to a Log File   ... to a log file. Logger provides different types of level like: warning, info and severe that have log records. Log records are written into a log file
Context Log Example Using Servlet
to server log file when servlet is called. In the following JSP page (message.jsp) we... file by log() method of ServletContext interface The Source code... in the log file which is shown like below: Download Source Code
Creating a File I/O using import scanner, io.* and text.*
Creating a File I/O using import scanner, io.* and text.*  open a file for reading and open another file for writing data. input file hours-int, hourly rate-double, name-string. output file name-string, hours-int, hourly rate
Use Log in Servlet Context
. The method context.log() writes the specified message to a servlet log file. The name and type of the servlet log file is specific to the servlet container... in the log file Download Source Code
Error in log file
Error in log file  Hi, I AM using Apache tomcat 6.0.16 server... of executing project i get following errors in "Apache Tomcat 6.0.16 log". Apr 17, 2011 11:57:57 AM org.apache.catalina.core.ApplicationContext log INFO: Marking
Error in log file
Error in log file  Hi, I AM using Apache tomcat 6.0.16 server... of executing project i get following errors in "Apache Tomcat 6.0.16 log". Apr 17, 2011 11:57:57 AM org.apache.catalina.core.ApplicationContext log INFO: Marking
Error in log file
Error in log file  Hi, I AM using Apache tomcat 6.0.16 server... of executing project i get following errors in "Apache Tomcat 6.0.16 log". Apr 17, 2011 11:57:57 AM org.apache.catalina.core.ApplicationContext log INFO: Marking
Creating a File in the directory.
Creating a file using HTML form action In this example, you will learn to make a query form asking to to create a file in PHP. You will have to write... of PHP code in the form. for creating a file in PHP, first declare a file name
log in page
log in page  hi all i want to create a login page in jsp which should be validated using ajax. please help me dong that with code...   Here...:</font></b></td> <td width="184"><input type="text
failure to log in
failure to log in  <blockquote> <p>Blockquote</p> </blockquote> <p>&lt;%@page contentType="text/html"%>...="Content-Type" content="text/html; charset=iso-8859-1" /> <title>
Where is servlet log file in net beans?
Where is servlet log file in net beans?  When you use context.log("some string"); then the string get written into the servlet log file. But where is the servlet log file in netbeans? I am using netbeans 6.9. I can't locate
Limiting the Size of a Log File in Java
Limiting the Size of a Log File in Java  ... to limit the size of a log file in Java. Log files haven't any boundation at the file creation time but Java provides the facility for limiting the size of a log
Write Text into File
Write Text into File      ... this example we are initialize string to write into file. We are creating file... to write text into file. At last close output file using close() method
creating pop up menu
creating pop up menu   how to create a pop up menu when a link in html page is clicked using jquery? and the link should be a text file   Please visit the following links: http://www.roseindia.net/tutorial/jquery
log in
log in  sir i designed one login.jsp page with one form, username,login,and one submit button .if i enter username and password its been verify the mydatabase in in table in the field of username and password while it s correct
Creating a setup file
Creating a setup file  How to create a setup file in tomcat as done in visual studio... could plz tell me as early as possible
Creating XMl file - XML
Creating XMl file   I went on this page: http://www.roseindia.net/xml/dom/createblankdomdocument.shtml and it shows me how to create an XML file, however there is something I don't understand. I have to create an XML file
creating a file in a directory
creating a file in a directory  hi i have tried all the file methods to create a file inside a directory but none of them r working some of them are new File ( ".", "C:/fileInRoot.txt" ) new File ( "myDir", "/otherDir" ) File
text file
text file  Hello can I modify the program below so that all the numerical data is stored in an external text file,that is the data contained in the array list.Thank you! mport java.util.*; import java.text.*; import
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.  I am reading the file using BufferedReader, then writing the output like this: String
text file
text file  Hi can you help me I have to modify the program below so that all the data held in it is stored in an external text file.So there should... at the start of the program from a seperate external text file.Thank you! mport
Creating an exe file
Creating an exe file  Hi All, I have developed java application using swing by Net Beans IDE. Now I need to convert my application into exe file... as an exe file. Please anyone suggest me.Thanks in Advance. Thanks, T.Thanga meena
creating instance of table in jsp
creating instance of table in jsp  i face senario look kie as follows... file is obviously a jsp page and shows the output in table manner. 3) now i want...()){ %> <tr> <td><input type="text" name="name" value="<
i need a program that will generate daily base log file dynamically - Log4J
i need a program that will generate daily base log file dynamically  i need a program that will generate daily base log file dynamically... produce a log file with today date and when next day comes, again it ll produce
JSP cannot log to FileAppender - Log4J
method. But when the LogClass is called from jsp file, no log file is created...JSP cannot log to FileAppender  Hi, Thank you for your attention... ----------------------------------------------------------------------------- ### direct log messages to stdout
creating tables as an xml document - XML
creating tables as an xml document  Create a table of a medal tally...(); DocumentBuilder docBuilder = builderFactory.newDocumentBuilder(); //creating a new...); System.out.println("Xml File Created Successfully"); } catch(Exception e
Write Text File to Table
_name, Emp_depart and sal). After creating a text file, you should establish... Write Text File to Table     ... the records of a simple text file and write (insert) into a simple table in MySQL
creating an .exe file - Java Beginners
creating an .exe file  how to create an .exe file in java? thanks in advance
Writing Log Records Only After a Condition Occurs
those have been written in a log file if  the "if" conditions... of program: Program takes a file name that has '.log' extension and checks it. If the given file exists then log records are written in a log file, when
Creating files in jpa project
; in package name text file... Creating files in jpa project       After creating "JPACRUDApplication" project
Creating methods in servlets - JSP-Servlet
Creating methods in servlets  I created servlet and jsp file.I... object to a file, and second method should read object from a file. Can you... FirstName < input type = "text" name="name">
Java error log
Java error log       Java error log is a error that arises due to internal error. A error logger is simple an object that is used to show an error log message
creating a jar file - JSP-Servlet
creating a jar file  Can you give me detail answer 1. i am having a servlet.class file in classes folder 2. web.xml file my questions are 1. where to place the html or jsp files 2. how to create a jar file and how can
Reading a text file in java
Reading a text file in java  What is the code for Reading a text file... in java.io.* package for reading and writing to a file in Java. To learn more about reading text file in Java see the tutorial Read File in Java. Thanks
Using Log Files
. In this program we are writing some information in log file.   The code... to a log file.   <%   String...Using Log Files      
Creating JAR File - Java Beginners
Creating JAR File  Respected Sir, I would like you to please help me, in letting me know, as to how to create JAR file from my JAVA source or class files. And what is this manifest file, and what changes needs to be done
Creating JAR File - Java Beginners
Creating JAR File  Respected Sir, Thankyou very much for your... to change the contents of my manifest file. I read somewhere regarding i have to add a line to my manifest file (i.e. Main-Class: mypackage.MyClass
Convert Text File to PDF file
Convert Text File to PDF file  Here is the way how to covert your Text file to PDF File, public class TextFileToPDF { private static void...(inLine); System.out.println("Text is inserted into pdf file
Sorting text file
Sorting text file  Hello friends, i'm writing search page for my local website. i'm storing all file list in text file. And also adding a value... according to begin value. Text File having list like this: 5| 3| can anyone
inserting text into text file using java application
inserting text into text file using java application  Hi, I want to insert a text or string into a text file using java application
Convert Text File to PDF file
Convert Text File to PDF file  import java.io.BufferedReader; import...); System.out.println("Text is inserted into pdf file"); document.close... FileReader( Input File)); String inLine = null
how to update the text file?
how to update the text file?  if my text file contains a string and integer in each line say,: aaa 200 bbb 500 ccc 400 i need a java code to update the integer value if my input String matches with the string in file. please
uploading a text file into a database
uploading a text file into a database  how to upload a text file... { static File file; public static void main(String[] args) throws Exception { JLabel label=new JLabel("Choose File
Creating Views
Creating Views Struts provides their own JSP tag library for creating view... data by model and handle them appropriately. For creating a view you should... password) { this.password = password; } } Note- The Name of the text field
Creating Message in JSON with JavaScript
Creating Message in JSON with JavaScript... about the JSON in JavaScript's some basic concepts of creating a simple object and creating an array of objects. Now we are going to discuss how to create
how to update the text file?
how to update the text file?  my textfile with name list.txt: Rice... in my text file, if the item i entered matches with item in text file.how can i...]; for(int i=0;i File file ; FileReader fr=null ; FileWriter

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.