How do i append each String on a different line in a JTextArea
Hi,
I have the following lines of code and I would like each line to append into the JTextArea on a separate line. I know I need to use \n but i forgot how to do it with the following code:
invoiceJTextArea.append(FirstName);
invoiceJTextArea.append(Surname);
invoiceJTextArea.append(Age);
At the moment, it prints right next to each other like this: JohnSmith28
Thanks for your help.
A JTextComponent will accept "\r\n", and it will seem
to work, but the "\r" will not be treated as part of
the line separator. And "\r" alone won't function as
a line separator--in fact, it won't be displayed at
all.
When you read text into a JTextComponent from a file
via the built-in read() method, all line separators
are converted to "\n". The type of separator used in
the file is saved as a property of the Document, and
when you write the text back to the file, they are
reconverted. Text pasted in from the clipboard also
undergoes this conversion (but I don't think it gets
reconverted when you copy or cut).
The issue of line separators is meant to be
completely transparent to the user. Programmers
usually don't have to think about it either, but we
do have the power to insert any whitespace character
into a text component. We need to be aware that only
spaces, tabs and linefeeds will render as expected.First off, I apologize for being a bit curt or dogmatic ... I was in a bit of a hurry.
Note thought that I did not state: Don't use '\n'.
What I did state as being wrong was your statement of:
"No, don't use the system line separator. JTextArea can only use "\n" as a line separator"
I have tried used the system line separator and it works. So I am not saying one should not use '\n', only that should not say the system line sep does not work.
Similar Messages
-
I just bought 3 memberships for adobe creative cloud with the same ID, how can I install each membership in 3 different computers.
Welcome to Adobe Forum,
You have CC for individual purchased which can be activated on two machines by the same Adobe ID.
How ever if you want to use it on more than two machine, you can cancel this order & buy the creative cloud for Team, in which you can buy the number of seats & assign them to as many user you would like to.
Each user can activate it two times with 100GB of space as compared to 20 GB space for CC for individual.
Regards,
Rajshree -
I HAVE TWO SHORT CUTS TO FIREFOX?HOW DO I MAKE EACH OPEN TO A DIFFERENT WEB SITE
On my Dell Dock I have two shortcuts for Firefox. One used to open automatically to my email account and the other to Firefox Home page (Google). Now they both open to my email account.
I can switch from one to the other but how do I get them to open to different sitesCreating a Desktop Shortcut to a web page
* https://support.mozilla.com/en-US/kb/Creating%20a%20desktop%20shortcut%20to%20a%20web%20page
Check and tell if its working. -
How do i append comments from 2 seperate data lines together
I am reporting on a table that in most cases gives me 1 record for each job - I am retrieving the job number and the door description. But some jobs have 2 doors and therefore two descriptions. I want to return one line per job with ideally the two door
descriptions appended to each other. Does anyone have any idea how I could do this please.on your tsql answer could you make it a
bit clearer please. This is my view so far; so what I want is 1 line per projid with concatenated comments.
SELECT PROJID, UNITCOMMENT
FROM dbo.MXM1002SURVEYLINES
WHERE (ITEMID = N'FH' OR
ITEMID = N'FJ' OR
ITEMID = N'FK') AND (PROJID LIKE N'%01232682%')
GROUP BY PROJID
just make it like below
SELECT PROJID,
STUFF((SELECT ',' + UNITCOMMENT
FROM dbo.MXM1002SURVEYLINES
WHERE (ITEMID = N'FH' OR
ITEMID = N'FJ' OR
ITEMID = N'FK') AND (PROJID LIKE N'%01232682%')
AND PROJID = p.PROJID
FOR XML PATH(''),TYPE).value('.','varchar(max)'),1,1,'') AS Comments
FROM (
SELECT DISTINCT PROJID
FROM dbo.MXM1002SURVEYLINES
WHERE (ITEMID = N'FH' OR
ITEMID = N'FJ' OR
ITEMID = N'FK') AND (PROJID LIKE N'%01232682%')
)p
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How do we do all this usually we use our phone numbers for the phone and the apple I'd at home now we have two iPad minis amd don't know what to do should we create a new apple I'd for them or what
For the iPad mini's you need to utililize an independent verifyible e-mail address for each of them. You can associate these two e-mail addresses with your single Aplle Id. If you supply the ipads with the same email address, you will not be able to make Facetime calls from one to the other, or if you make an FT call from your phones, both ipads would respond. In other words, if you want the ipads to function as individual devices they each need a unique e-mail address assigned to them. To help you with this, I'm including a link to an Apple informational page that will help you in adding neww e-mail addresses to your Apple ID.
http://support.apple.com/kb/HE68 -
How can I Split the String in to different strings
Hi All,
I have created a table A
If i select * from A
Result is :
1,2,3,4 - Line 1
11,222,3222,422 - Line 2
Now i what to split the data like by using substr and instr
A , B , C , D
1 2 3 4
11 222 3222 422
Can any one help me in this query,i need the full query..pls
Regardsexcuse me..
it's unclear ..
Now i what to split the data like by using substr and instr
A , B , C , D
1 2 3 4
11 222 3222 422
are u trying to select same result from table A to other tables B,C,D
what r the fields number u have,what their datatypes..?
Regards,
Abdetu.. -
The listed features "file...help" were in different places on a prior version of Firefox. About three weeks ago, I tried to get some updates to Firefox. A few days later I noticed the changes were made. How and why that happened, I don't know.
Can you attach a screenshot?
*http://en.wikipedia.org/wiki/Screenshot
Use a compressed image type like PNG or JPG to save the screenshot and make sure that you do not exceed the maximum file size (1 MB).
You see the orange (on Linux gray) Firefox button if the Menu Bar is hidden.<br />
You can hide the Menu bar via View > Toolbars, also accessible via Firefox > Options.<br />
If you need to access the hidden Menu bar then press F10 or hold down the Alt key to make the Menu Bar appear temporarily.<br />
You can place the Tab Bar on top.
* View > Toolbars : [ ] Menu Bar
* View > Toolbars : [X] Tabs on Top -
Reading Each String From a text File
Hello everyone...,
I've a doubt in File...cos am not aware of File.....Could anyone
plz tell me how do i read each String from a text file and store those Strings in each File...For example if a file contains "Java Tchnology forums, File handling in Java"...
The output should be like this... Each file should contains each String....i.e..., Java-File1,Technology-File2...and so on....Plz anyone help meThe Java� Tutorials > Essential Classes: Basic I/O
-
How do I copy the string portion of an enum into the string portion of a cluster?
I want to do this for the an entire array of clusters. I'm trying to use a for loop. Can't figure out how to parse the string portion of the enum into the string portion of the cluster.
Alternatively, I'd be happy if I could figure out some way to tie the enum to the array of clusters, but I figure that gets problematic.
DH
Solved!
Go to Solution.Dark Hollow wrote:
OK, let's say that the enumerated type has N elements. I want to initialize an N element array of strings. How do I reference each string in the enumerated type to get to each string?
Easy way to do this is to use GetNumericInfo.vi, part of the Variant library, found in vi.lib\utility\VariantDataType\GetNumericInfo.vi. Wire your enumeration to the Variant input; one of the outputs is an array of the strings in the enumerated type.
The more complicated way is a for loop, in which you typecast the iterator terminal value to the enumerated type, then use Format Value. You can get the maximum value of the enumeration by casting 0 to the enumerated type, then decrementing; cast that back to a numeric and add one to get the right value to wire to the N terminal.
EDIT: just thought I'd add, since RavensFan's reply popped up while I was writing mine - I don't like the Strings[] approach because it doesn't work on RT targets, and I lost a lot of time once due to this trying to figure out why my code wouldn't run properly on an RT system but worked great on my development computer. -
I need to append a string to another string
I'm working with some inherited code, I'm a Colf Fusion
novice myself, and I'm trying to make this order form display the
correct data. The problem is a lot of data in the database is
missing. Description in the QStockDB query can contain a lot of
stuff. For our full color work the text "4/0", "4/BLACK", and "4/4"
are consistent so I'm changing the newitem (I know, not very
descriptive but it's not my code) to CMYK Printing.
<cfif #QStockDB.description# contains "4/0"><cfset
newitem = "CMYK Printing"></cfif>
<cfif #QStockDB.description# contains
"4/4/BLACK"><cfset newitem = "CMYK Printing"></cfif>
<cfif #QStockDB.description# contains "4/4"><cfset
newitem = "CMYK Printing"></cfif>
I want to then go back through description and compare it
more to add more description. For instance with this:
<cfif #QStockDB.description# contains "12 pt"><cfset
newitem = newitem + " - BC"></cfif>
I know that the job is a business card. So I want to append
the newitem variable with " - BC". Likewise:
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem + " - Catalog
Sheets"></cfif>
displays CMYK Printing - Catalog Sheets. Or, it should... or,
more precisely, I want it to. :)
How do I append a string to another string?+ is the addiion operator and works with numbers. Because
your string is a ...well, string... you need to use an ampersand.
Thus, instead of:
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem + " - Catalog
Sheets"></cfif>
Use...
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem & " - Catalog
Sheets"></cfif>
<cfoutput>#newitem#</cfoutput>
At least I think that will work - haven't tested it
though. -
Append a string to a file without overwritting.
OK, let's do this as easy as can be...
I have a file "A.txt" and its contents is:
AAAAAAAAAAIf we retreive the File data, its length is 10.
Now, I have the next code:
import java.io.*;
public class MyClass {
public static void writeToFile(File f, String writeThis, int where) throws IOException, FileNotFoundException {
RandomAccessFile raf = new RandomAccessFile(f, "rw");
raf.seek((long)where);
raf.writeBytes(writeThis);
raf.close();
public static void main(String args[]){
try {
writeToFile(new File("A.txt"), "java", 3);
} catch (Exception anyE) {}
}This is what I want:
File A.txt contents
AAAjavaAAAAAAA
^ Appended to the fileNow the file data length is 14, 10 A's + java (4)
This is what I get:
AAAjavaAAA
^ Overwrote the file contents.Now the file data length is still 10, Java overwrote 4 A's.
How can I append a string to a file at any desired position without overwriting nothing.
I've checked all java.io package and I found that only RandomAccessFile class allow me to have a file pointer in order to read from there.
It's important not to append data at the end of the file, I have some tokens there in my app.Hi, i am trying to do the same thing. Can u use a randomaccessfile and seek to the pt where u want to insert. save that location. store the data from that pt to the end of the file in a string buffer. then append the string to be inserted at the position u had saved earlier. and then append the string buffer to it. think this should do it. i dont know if it works.
i had another problem .. i was looking to delete some portion from a file and maintain the continuity. for eg. i have file containing "aaaaajavaaaaaa" and i want to remove java .. from it resulting in "aaaaaaaaaa". is there a easier way to do it. let me know thanks -
Grabbing each String from String[] ?
Hi guys,
how do i grab each String from a String[] and store it separately for later use? Ex i have a String[] {"Tom M F A D C A","SUE F M D D D D"};
Now i want to break it into tokens(im using StringTokenizer for that)
and store each value in some Collection ex Hashtable,Vector etc.
I cannot store it into a Collection? Please help...
thanks in advance,
SachinIs this what you had in mind?
Collection stringArraySplitter(String[] sa) {
Collection list= new ArrayList();
for (int i= 0; i < sa.length; ++i) {
StringTokenizer st= new StringTokenizer(sa[ i ]);
while (st.hasMoreTokens())
list.add(st.nextToken());
return list;
} kind regards -
hi there
the following code reads a line from a file,
while (true)
try
line = br.readLine();
catch (IOException e)
System.out.println("Error reading data file");
System.exit(1);
if (line == null) break;
st = new StringTokenizer(line, delimiterString);
n = st.countTokens();
if (first == 0) first = n;
if (n != first)
System.out.println("Data format error!");
System.exit(1);
how will i append the line to itself each time the loop runs? the line should contain all the lines in the file, not just a single line. thank youYou can make a StringBuffer object with the same scope as the line String and keep appending to the StringBuffer. You can use StringBuffer's toString() method to get a String back when you need it. You can also do this with a String instead of a StringBuffer using +=, but the String buffer is a lot more efficient.
StringBuffer wholeFile = new StringBuffer();
while (true)
try
line = br.readLine();
wholeFile.append(line); // or put this wherever it makes most sense
catch (IOException e)
System.out.println("Error reading data file");
System.exit(1);
if (line == null) break;
st = new StringTokenizer(line, delimiterString);
n = st.countTokens();
if (first == 0) first = n;
if (n != first)
System.out.println("Data format error!");
System.exit(1);
} -
How to append a string whose content is XML file to the child of other XML?
Hi guys,
I have a question:
I obtain a string which is actually a response from HTTP servlet, and I want to append this string as child of another XML, how can I do it? Is there any method to convert string to XML node, opposite to the method "render_2_string"?
Thanks in advance
Message was edited by: Liying WangIf I understand your question correctly, this may be helpful.
types: begin of myStructure,
myNumber type n,
myChar type c,
end of myStructure.
Data:
IXML Type Ref To IF_IXML,
XMLDOC Type Ref To IF_IXML_DOCUMENT,
RC Type SY-SUBRC.
data rootNode type ref to if_ixml_element.
data newNode type ref to if_ixml_element.
data sourceString type string.
types
ixml = cl_ixml=>create( ).
xmlDoc = ixml->create_document( ).
rootNode = xmlDoc->create_element( 'RootElement' ).
setAttributesFromStructure( node = rootNode structure =
mystructure ).
newNode = xmlDoc->create_element( 'newNodeAdded' ).
if sourceString is not initial.
rc = newNode->IF_IXML_NODE~SET_VALUE( sourceString ).
endif.
add navigation graph entry
rc = rootNode->append_child( newNode ).
Quack -
How to append the string into blob content
the blob column will have a string with comma separated values which needs to be changed to column wise data and update it back with the existing BLOB content.
string like:-'V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M'
after i got splitting the values to column wise:
V
CTMF
1.0
M
ICD-9 to 10 CM
CODE_COMMENTS_UPLOAD
0
A
bsns
2012-04-01
Author
pa admin
Comment
50 Record Map
F
Vascular
C
M
finally i need the blob append data output look like below,please do the needful................
blob_value
V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M
V
CTMF
1.0
M
ICD-9 to 10 CM
CODE_COMMENTS_UPLOAD
0
A
bsns
2012-04-01
Author
pa admin
Comment
50 Record Map
F
Vascular
C
Mactually
my blob column values is:
V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M
splitting column wise data is:-**
V
CTMF
1.0
M
ICD-9 to 10 CM
CODE_COMMENTS_UPLOAD
0
A
bsns
2012-04-01
Author
pa admin
Comment
50 Record Map
F
Vascular
C
M
now i am appending the string to blob content at the end of the line only like
V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,MVCTMF1.0MICD-9 to 10 CMCODE_COMMENTS_UPLOAD0Absns2012-04-01Authorpa adminComment50 Record MapFVascularCM
but my requirement is should be to append the column wise data to existing blob column as new line like:
V,CTMF,1.0,M,ICD-9 to 10 CM,CODE_COMMENTS_UPLOAD,0,A,bsns,2012-04-01,Author,pa admin,Comment,50 Record Map,F,Vascular,C,M
VCTMF1.0MICD-9 to 10 CMCODE_COMMENTS_UPLOAD0Absns2012-04-01Authorpa adminComment50 Record MapFVascularCM
my procedure:
create or replace
PROCEDURE PR_TEST_BLOB2 IS
RES_BLOB CLOB;
DEST_BLOB BLOB;
SRC_BLOB BLOB;
CURSOR CUR_TEST_BLOB2 IS
SELECT REGEXP_SUBSTR(STR, '[^,]+', 1, LEVEL) FROM (SELECT UTL_RAW.CAST_TO_VARCHAR2(BLOB_VALUE) STR FROM TEST_BLOB2 WHERE TEST_ID=10)
CONNECT BY LEVEL <= LENGTH(STR) - LENGTH(REPLACE(STR,','))+1;
BEGIN
OPEN CUR_TEST_BLOB2;
LOOP
FETCH CUR_TEST_BLOB2 INTO RES_BLOB;
EXIT WHEN CUR_TEST_BLOB2%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(RES_BLOB);
DEST_BLOB:=UTL_RAW.CAST_TO_RAW(RES_BLOB);--converting clob to blob;
SELECT BLOB_VALUE INTO SRC_BLOB
FROM TEST_BLOB2
WHERE TEST_ID = 10 FOR UPDATE;
--move the blob values to source file
DBMS_LOB.APPEND(SRC_BLOB,DEST_BLOB);-- append the blob values
COMMIT;
END LOOP;
CLOSE CUR_TEST_BLOB2;
END;
could you please help me.
Maybe you are looking for
-
Pdf file not opening on pushing fdf file with F key in Adobe Reader
Well i am a novice developer in case of PDF Development. The problem which i am facing is:- In our application a PDF document submits the data to server and server sends back FDF to client with f key as http path of PDF which is present on web server
-
How to compile a .xsd in runtime?
hi, is there a way to compile .xsd schemes by calling the xjc in a java application? (not exec())
-
OfficeJet 6500 E709n Black XL cartridge, newly installed, expiration date 2012 It won't print. The printer works; just nothing that's supposed to be in black shows up. I've run a printer head cleaning and cartridge alignment. With the former, it pr
-
I cant connect my iPod 3g anymore...
I've recently had to get my computer reimaged, and since I have gotten it back I have not been able to authorize my iPod to it. I really dont want to loose all of the files on my iPod, or all of the playlists. I have re-authorized my apple ID to the
-
Scheduling Issue at subassembly level
Hi Experts, In REM scenario we are having two levels of BOM e.g. Finished Good X and subassembly Y both are produced in house with REM on different production lines. The total time taken to produce one finish good is 2hrs which includes 1 hour for pr