How to save the text from text area back to a text file?
Hi all,
Now I am doing a small panel which containts a JTextArea, this TextArea will read the content from a text file, then display the content of the text file on the TextArea itself.
My idea is, allow the user to modify the content in the textarea (I set it Editable=true;), then save it. After the user press the save button, the content in the text file will be updated accordng to the user;s modification on TextArea.
I had done the displaying part by using JavaI/O (BufferReader), now any expert here know how to update the TextArea content back to the text file itself? PLease teach me, THANKS !!!
NOw I had manage to clear out the error, but now the problem is when I click on the 'save' button, this function clear out the entire text file for me !!!
The code are as below:
if(e.getSource()== vButtons[0])
try{
String str;
String Ky = tArea.getText();
BufferedWriter buffWrite=null;
BufferedWriter in1 = new BufferedWriter(new FileWriter("Keyword.txt"));
buffWrite.write(Ky);
buffWrite.flush();
buffWrite.close();
in1.close();
catch (IOException ex) {
ex.printStackTrace();
if(e.getSource()== vButtons[1])
new panel();
dispose();
if(e.getSource()== vButtons[2])
System.exit(0);
} Please tell me how to save the TextArea to the text file, THANKS !!!
Similar Messages
-
How to save the string from JTextFied to database?
can i know how to save the data from JTextFied to databse. Is it using update?
The most straightforward way would be something like:
String myKey=myKeyField.getText();
String foo=fooField.getText();
String sql="update mytable set foo='"+foo+"' where mykey='"+myKey+"'";
connection.createStatement().executeUpdate(sql);
This example assumes that the input fields cannot possibly contain quotes or the string won't be built correctly. Which by the way brings up a question I'd be interested in hearing others answer: What do you do about this? Sometimes I use PreparedStatement which handles that problem, other times I write my own little function to escape the string properly.
You can also read the record into a ResultSet and use ResultSet.update(). I'm mostly using mySql and I found that in mySql ResultSet.update just creates a SQL update statement like I did above and executes it, so the only real advantage would be if you find the syntax more convenient. Perhaps other database drivers do something different that would give other pros and cons. -
I had to restore my computer to the factory settings, which means my itunes library was lost except for what was on my ipod nano. How do pull the songs from my ipod back onto my computer? I have over 200 songs. There is no way I can re-purchase them! Any help?
How to use your iPod to move your music to a new computer
-
How to save the "void * inData " in filter plug-in to a file?
In a filter plug-in, we want to save the image data "void * inData " to a new image file. How to do it?
Thanks a lot.On the other hand,
http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html
includes vital information missing in the other reference. This is
more accessible and the section "The pixel data" is vital. However,
when it says "The first byte represents the red part, the second the
green and the third the blue part", this is simply wrong. Caveat
emptor.
Aandi Inston -
How to save the data from AI Read.vi?
Hi,
The main target is that testing the strength of a object which is extended by a force. The desired results are
1. The strength of object under the force(main target, I am trying now);
2. Displacement of object being extended(I have mimicly done);
3. Images of deformation of the object extended(I have mimicly done).
4. The sub procedure will stop when the object under testing is broken. I intend to use the big pulse from force sensor by analizing the data acquired.( it is more difficult if using machine vision).
What I am mainly trying to do now is implementation of a sub vi to collect the data which is acquired from channel 0 of PCI-6052E which is connected to a force sensor. I have tried to use an existing exam
ple as attached with some modifications. I have tested the data from the sensor by comparing to measurement by multimeter and it takes sense. But
1. I still don't know how to save data displayed by AI Read.vi? And use what kind data type could save more memory?
2. I think that memory management is very important because each points of the result includes its strength, image and displacement. How can I acquire enough significant points for the final results being reliable and save these data down to an array or cluster synchronously? (each sub procedure has no time limited)
3.Because I think that a continuous data acquisition would occupy ALL CPU TIME and their related images and displacements would have no chance to be taken down by CPU at the same moment. Am I right?--I am sure that it is not very difficult problem but my mind is still in caose and the time is quite limited to me now.
I am looking for your sugguestion or solution or control philosophy too. You can modify the fi
le attached if you can. I will learn from your idea.
Thank you very much for your time and energy!
Your
Swedlin
Attachments:
Acquire_N_Scans_1_10.vi 75 KBHello;
Regarding your question on the data type that would use less storage space, the answer is binary type. Actually, you can use another shipping example as start point of your application. The example I'm mentioning is a data logger, that saves binary data to a file on your hard drive. You can find that example at Search Examples->I/O Interfaces->Data Acquisition->Data Logger->High Speed Data Logger.
Regarding your question about the CPU time, the statement is valid. In case you use a synchronous AI task, the CPU execution will get stuck inside the AI Read.vi untill the buffer is ready to be read. One thing you can do about that is to change the acquisition task to be asynchronous. There is a good example in Labview showing how you can accomplish that.
You can find the example at Search Examples->I/O Interfaces->Data Acquisition->Analog Input->DAQ Occurrences.
You can combine both examples to accomplish the task you need.
Hope this helps.
Filipe A.
Applications Engineer
National Instruments -
How to save the data from alv output
My ALV output is editable one.I want that user can edit the output and save the output details into database.How to do it?
Moderator Message: Basic Question. This site is not an alternative for your Consultancy work. Put some effort of your own before turning to the forums for help. This is your LAST warning. One more violation will lead to Account deletion.
Edited by: kishan P on Dec 6, 2010 6:45 PMHi
U need to implement an user_command and manage the functionality SAVE: when the user press SAVE you'll store the data into db.
There are several programs demo in SAP and many solution in SCN forum: try to search it
Max
Moderator message: please think twice before replying. By now you should know which type of questions will be locked, so no point in replying, in a double sense.
Edited by: Thomas Zloch on Dec 6, 2010 2:49 PM -
How to save the value from JTextFormattedField using TAB key in lostFocus
Can you, please help me with this problem:
I want to have saved new value in JTextFormattedField after I use TAB kye.
I tried with focusLost, then setting setFocusTraversalKeys etc.
It looks simple, but !?
ThanksI also tried the JFormattedTextField for the IPAddress Object which I created but it would't work that well I have a bad experience with these TextFields it showed me the formate 0.0.0.0 but when I entered the text in it, it jumps of after tow digits in each column
-
Hi, My computer recently got wiped. When everything was re-installed I found that I had no music in my itunes account. It is all on my ipod touch (and very old ipod) but I cannot figure out how to transfer it from the ipod touch into my itunes. Can anyone help? Thanks in advance A
Syncing to a "New" Computer or replacing a "crashed" Hard Drive: Apple Support Communities
-
How to save the data present in TEXT BOX?
Hi friends i am able to create a text editor in one of my screen but i want to know how to save the data when the text is entered in that text box and retrive when they open the screen?
Hi ,
Please check the format below since it is based on a working code
first you need to create a text in s010 function module...
there should be some key based on which you plan to save the text..imagine it is Purchase order then..PO+item numner is always unique.eg:0090010(900PO/item10).so in the code you can append these two and they will be unique..so you can always retrieve them,overwrite,save them anytime you need
**************data declarations
TYPES: BEGIN OF TY_EDITOR,
EDIT(254) TYPE C,
END OF TY_EDITOR.
data: int_line type table of tline with header line.
data: gw_thead like thead.
data: int_table type standard table of ty_editor.
****************fill header..from SO10 t-code..when you save you need the unique key..youfill it here and pass it in save_text function module
GW_THEAD-TDNAME = loc_nam. " unique key for the text -> our unique key to identify the text
GW_THEAD-TDID = 'ST'. " Text ID from SO10
GW_THEAD-TDSPRAS = SY-LANGU. "current language
GW_THEAD-TDOBJECT = 'ZXXX'. "name of the text object created in SO10
*To Read from Container and get data to int_table
CALL METHOD EDITOR ->GET_TEXT_AS_R3TABLE
IMPORTING
TABLE = int_table
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop data from int_table and save to int_line-tdline appending it.
*save the text
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
HEADER = GW_THEAD
TABLES
LINES = InT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
OBJECT = 4
OTHERS = 5.
IF SY-SUBRC 0.
ENDIF.
*To pass to Container
CALL METHOD EDITOR ->SET_TEXT
hope that the above sample with helps you solve the problem
Please check and revert,
Reward if helpful
Regards
Byju -
Hello, for a multilingual catalog project I would have to know how and with what tool I can place text from Excel or a database in text frames / tables. The basic idea is to provide the text box with an ID (eg << text_eng_art_nr_987654>>) and above to make the connection. Does anyone have a tip. Thanks in advance !!!
BerndData merge is really useful in many circumstances, but my first question would be about the size of the project. A really large catalog might be better handled by processing an IDML in some kind of translation memory tool.
If all of your multilingual content is already in Excel, then it's probably best handled with a Data Merge. Note that you can't save Unicode CSV out of Excel for the merge, so for many languages you'll need to save "Unicode Text" out of Excel and tweak your import settings when you select a Data Source for encoding (Unicode) and delimiter (tab instead of comma). -
how can i retrieve texts from an earlier back up without changing all the other settings on my iphone?
You can't. Restoring from a backup is all or none.
You can use a utility such as this one to extract the messages from the backup on your computer but you can't re-transfer the messages to the Messages app on your iPhone.
http://msb.macsupport-pr.com/ -
How can I stop Siri from speaking certain words as I text??? It is so annoying and unnecessary!
Actually, I did notice the thread age. However, this phenomenon only appeared with mu phone in the last week.
You and I both would hope that it was corrected long ago, but that is evidently not the case.
I added information that will be useful for anyone else encountering my recent situation, now or perhaps in some distant future.
If you are aggravated by notices re: threads over two years old, perhaps you should disengage from the thread in lieu of making
snarky remarks to those of us still getting useful information from them. -
How to save the bean area content to the database
DB version:10g
forms version:10g
Hi Guys,
I have used text editor PJC/java bean in my screen where i have attched it to "bean area" field.Iam able to do all the changes to the to the text entered in this "bean area" but when i save this in the database it says no changes to save.in my table the column type is Varchar2.
any ideas of how to save the changes of a bean area to the database???
regards@François Degrelle -Ya frank i have already checked Get_Custom_Property() but the problem is this is returning the HTML code like
html>
<head>
</head>
<body>
This is a <b>styled</b> (<i><u>HTML</u></i>) text<br><b><font color="#0066FF" face="Arial">
displayed</font></b> and <b><font color="#008000" face="Arial">edited</font></b><br>
in an <b><font color="#FF0000" face="Arial">Oracle Forms</font></b> application
</body>
</html>
but want the data to be in the formatted so that i can store the data in the column and retrieve formatted text into the text field so that user can see only the formatted text that is lets say
shdjshdsjdsdsdlas -original text
shdjshdsjdsdsdlas -formatted text
now i want to strore shdjshdsjdsdsdlas this text into teh database so that when i retrieve shdjshdsjdsdsdlas this data should be shown.
regards
Edited by: user123 on May 27, 2011 4:22 PM -
How can i save the data from the Oracle database to my local directory
How can i save the data from the Oracle database to my local directory instead Of saving the data file to the Directory created on the Oracle Server ?
I require to design the Procedure which will pull the data from various tables and needs to store the data in the Client's local directory.Since SQL*PLUS runs on the client, you can use SQL*PLUS to spool data to your local drive.
You could also use the database to write a a specified drive where all users have access to (mapped network drive, e.g.). I wouldn't recommend doing it that way, but it is sometimes useful when the files are created in some nightly batch run. -
How to get the source code of an HTML page in Text file Through J2EE
How to get the source code of an HTML page in Text file Through J2EE?
Huh? If you want something like your browser's "view source" command, simply use a URLConnection and read in the data from the URL in question. If the HTML page is instead locally on your machine, use a FileInputStream. There's no magic invovled either way.
- Saish
Maybe you are looking for
-
Hi, We have BOE 3.1 SP2 with PixPack 2.2 running on Windows Server 2003 R2 SP2 x64 In InfoView, when scheduling a Web Intelligent Report, nothing shows in my List of Values in the Prompts. I hit the Refresh Values button and nothing comes up also. I'
-
Need to revert a universal app to iphone in iTunes connect
The question is can we replace a Universal App with and Iphone app in iTunes connect and what are the steps. In this case the iPhone app is the app the Universal app replaced in the first place. Our client claims you cannot replace a Universal app wi
-
Table views/sprocs not showing in Data Source Explorer
i have a database connection and is in good health. the tree node for the database lists all of the folders expected, but only the Tables folder is populated with actual tables in the database. the views and stored procedures are not showing even w
-
IgonoreRecordsetName in JMS possible?
Hi All, Reopening the below thread How to ignore Recordset name in XML(Sender JMS Adapter)? I am having complex header and item structure in source and using the paramater xml.conversionType = StrcutPlain2XML
-
No more EXPORT (Share) into File
Hi, without wanting to critizise iPhoto 6, actually, almost everything worked out without issues in my case, I am missing out on one function which I used on iPhoto 5 a lot. The SHARE to FILE function. I really used it a lot to convert a certain amou