Home Discussion Discuss: Java Write

  • read and write to textFilebegginer java May 26, 2011 at 2:32 PM

    hi..help me please in my project the user input two string &picture i want to write them to textFile but if user add again i want mix its input with other input then in read textFile just read determine three input ..this my code public void actionPerformed(ActionEvent e) { ImageIcon icon=new ImageIcon(); String s1=textField1.getText(); String s2=textField2.getText(); String image =(icon.getImage()).toString(); String k="*"; String text=s1+s2+image+k; String fileName = "c:/MyVocabulary.text"; String[]a=text.split(k); if (((JButton) e.getSource()).getName().equals("Close")) { prj.setVisible(false); } if (((JButton) e.getSource()).getName().equals("Browse")) { JFileChooser fc = new JFileChooser(); // create object of file // Browser File file; // create file variable fc.setDialogTitle("Open File"); // set Title int result = fc.showOpenDialog(prj); // make it visible if (result == JFileChooser.APPROVE_OPTION) { // if click ok file = fc.getSelectedFile();// get the selected file textArea1.setImage(icon.getImage()); // update textField3 textField3.setText(file.getPath()); } } if (((JButton) e.getSource()).getName().equals("Add")) { File file1=new File(fileName); FileWriter fw=new FileWriter(file1); BufferedWriter bfw = new BufferedWriter(fw); bfw.write(text); bfw.newLine(); bfw.close(); } else if (((JButton) e.getSource()).getName().equals("Search")) { File file1=new File(fileName); FileReader fr=new FileReader(file1); BufferedReader bfr =new BufferedReader(fr); for (int i=0;i<a.length;i++){ if(a[i].equals(s1)){ String m=""; while((m=bfr.readLine())!=null){ m=m+"\n"; } System.out.println(m); } bfr.close(); } } } }

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java Beginners

write spreadsheet
write spreadsheet  what is the java code to write a spreadsheet to database 

Java Beginners

write spreadsheet
write spreadsheet  what is the java code to write a spreadsheet to database 

Java Beginners

write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java 

Java Beginners

WRITE AND TEST
WRITE AND TEST   WRITE AND TEST PROGRAM TO ACCEPT A STRING? 1).WHICH STARTS WITH 'S' OR 's' 2).ENDS WITH "nd" 3) THE LENGTH OF THE STRING SHOULD BE 10 OR LESS 

Java Beginners

Write to PDF
Write to PDF  Hi, Fairly new to this. I want to create a PDF file as a server call, with text/images sent to the app. Seeing that this will have to be a plugin, how do I go about making it a valid plugin for the server 

Java Beginners

Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory 

Programming Tutorials

Ajax Write
Ajax Write       ajaxWrite is a web-based word processor that can read and write Microsoft Word and other standard document formats Read full Description 

Mobile Applications Questions

write data to plist
write data to plist  How to write data to plist file in XCode 

Java Beginners

write a java program
write a java program  write a program to print '*' in a circular form 

Java Beginners

How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks 

Java Beginners

Write data in doc file
Write data in doc file  How to write data or string in word file 

Java Beginners

Write String in Word document
Write String in Word document  How to read and write strings in word document 

Java Beginners

How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks 

Java Beginners

Read and write file
Read and write file  HI, How to read and write file from Java program? Thanks   Hi, See the following tutorials: Java Write To File Read File Thanks 

Java Beginners

write a programm using java
write a programm using java  print the following using java programming 

Framework Questions

write code in c#
write code in c#  sir I want to write a save and save as code in the c#(windosForm).Please help me 

Java Beginners

write java prgram
write java prgram  write java program to offer a menu which contains 3 choices to make calculation on 3 shapes.use method for each calculation 

Java Beginners

WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order 

Java Interview Questions

Write java program?
Write java program?  1 11 121 1331 14641 15101051 

Java Interview Questions

write the java program?
write the java program?  1 11 121 1331 14641 15101051 

Java Interview Questions

write the java program?
write the java program?  1 11 121 1331 14641 15101051 

Java Interview Questions

Write java program?
Write java program?  1 11 121 1331 14641 15101051 

Java Beginners

Java write to file
Java write to file  How to write to a file in Java? Is there any good example code here? Thanks   Hi, Java is one of the best... files. You can easily use the the FileWriter and BufferedWriter to write data 

Java Beginners

How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... to write in File of Java Program... the (BufferedReader) constructor. So that we write some data suing 

Java Beginners

write a program to print
write a program to print   write a program to print following 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1 

Java Interview Questions

Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers 

JSP Servlet Questions

Write cookie and session to textfile?
Write cookie and session to textfile?  I want to store all data from user submisstion into a textfile, include session and cookie. Thanks 

Java Beginners

how to write code for this output?
how to write code for this output?   1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 

JavaScript Questions

Write JQUERY Code
Write JQUERY Code  Hi, Iam swathi.I created the table in the below format.can u please write the jquery code of this table..and my requirement is when i click the submit button in the "Name" filed beside show some mesg like 

JavaScript Questions

Write JQUERY Code
Write JQUERY Code  Hi, Iam swathi.I created the table in the below format.can u please write the jquery code of this table..and my requirement is when i click the submit button in the "Name" filed beside show some mesg like 

DMCA.com