How to write Strings in a text file with BufferedWriter
I've got a Vector object full of Strings objects, I'm interested in wrinting these Strings in a text file with a BufferedWriter , I would apreciate some code, thank you
http://java.sun.com/products/jdk/1.2/docs/api/java/io/BufferedWriter.html
"PrintWriter out = new PrintWriter(new BufferedWriter((new FileWriter("foo.out")));"
Similar Messages
-
How to output strings to an text file and excel file
Hi guys,
I am writing a simple application taht process some string inputs from user using a simple GUI. The GUI consists of a series of
textfields which the user can enter names, age, addresses....etc
Once they complete filling up that GUI form, they click SUBMIT. All the values will then be read. These strings are then required to be output to 2 files
1. To a text file which I can open it and read it anytime I wish.
2. To an excel file which follows a specific format. That is, all names will be written to column B, all ages will be written to column C...etc
The programme is expected to keep running allow the user to enter details of multiple persons(some 300 sets of data of different persons) until he clicks on End program.
Please advise how I can output the strings to
1. Text file
2. Excel file.
Many many thanks. I need this for one of my project which is due so so soon...... :((
Regards
David1. Text file
See link to "Documentation - Tutorials" on the left
side of this page.
2. Excel file
Dont try to write the real excel format (if you want
to do it soon).
- write data to a plain text file.
- Use tab stops for separation of values.
- Name file as excel file. (*.xls)
If you double click this file, excel will import data
and insert it to a table in the right order by
itself.
Excel can save this as real .xls now.
Anyone here with a better idea? (Try to learn by
myself)good thing to know for the excel tip :)
thx -
How to write empty line in text file
hey
i want to insert one empty line in text file.
how to write this.
i declared
data: emptyrec(240) type c value space,
and used
TRANSFER emptyrec to e_file.
but its not inserting empty line in the record.
is there any special way have to do.
ambichan.hai anand,
I am posting the code snippet.
i have commented that transfer line in '----
' like this
pls refer below.
ambichan
DATA: PAGENO(4) TYPE N VALUE 1,
DATAKBN(2) TYPE N VALUE 1,
SUBNO(3) TYPE N VALUE 1,
VPAGENO(4) TYPE C,
VDATAKBN(2) TYPE C,
VSUBNO(3) TYPE C,
VREC(255) TYPE C,
VRECORD(255) TYPE C,
EMPTYREC(255) TYPE C VALUE SPACE,
VCODE(10) TYPE C,
VNAME2(35) TYPE C,
VPAYDAT(10) TYPE C,
VSGTXT(60) TYPE C VALUE SPACE,
VSGTXT1(10) TYPE C,
VKINGAKU(15) TYPE C VALUE SPACE,
VBIKKO(30) TYPE C VALUE SPACE,
VBELNR(10) TYPE C VALUE SPACE,
VDMBTR(15) TYPE C,
VGLT0-KSLVT(15) TYPE C,
VGLT0-TSL01(15) TYPE C,
VGLT0-TSL02(15) TYPE C,
VGLT0-TSL03(15) TYPE C,
VGLT0-TSL04(15) TYPE C,
VGLT0-TSL05(15) TYPE C,
VKIN(15) TYPE C,
VTEGA(15) TYPE C.
FORM FRM_OUTPUT_DATA.
SORT ITAB_OUTPUT_SUMMARY BY LIFNR DTYPE.
SORT ITAB_OUTPUT_ITEMS BY LIFNR DTYPE BELNR.
IF P_DISP = 'X'."checkボクスを選ぶ場合、ファイル作成処理へ行く
OPEN DATASET E_FILE FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC <> 0.
WRITE: 'error',SY-SUBRC.
EXIT.
ENDIF.
LOOP AT ITAB_LIFNR.
PERFORM LISTDATA.
PAGENO = PAGENO + 1.
SUBNO = 1.
ENDLOOP.
CLOSE DATASET E_FILE."ファイルクローズ
ENDFORM. " End of frm_output_data
FORM LISTDATA.
DATA:
WK_PAY_AMOUNT LIKE BSEG-DMBTR, " 純支払額算出用
VWK_PAY_AMOUNT(15) TYPE C,
GLT0-TSL05_VAL LIKE GLT0-TSL05.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 1.
BSIK-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
GLT0-TSL01 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 2. " 区分:2
GLT0-TSL02 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 3. " 区分:3
GLT0-TSL03 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 4. " 区分:4
GLT0-TSL04 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 5. " 区分:5
GLT0-TSL05 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
glt0-tsl05 = glt0-tsl05 + glt0-tsl04.
WK_PAY_AMOUNT = GLT0-TSL05 + GLT0-TSL04.
CHECK WK_SUBRC = 0.
BSEG-KOART = ' '. 情報不要
CLEAR: BSEG-SGTXT, BSEG-DMBTR, TGSBT-GTEXT, BKPF-BELNR.
BSEG-KOART = 'Y'. " フラグ:ヘッダに相殺額を出力
CLEAR: BSAK-DMBTR.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 6. " 区分:6
BSAK-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSAK-DMBTR.
WRITE : / PAGENO,
SUBNO,
DATAKBN,
ITAB_LIFNR-LIFNR,
ITAB_LIFNR-NAME2(25),
P_PAY_T,
GLT0-TSL01,
GLT0-TSL02,
GLT0-TSL03,
GLT0-TSL04,
GLT0-TSL05.
VPAGENO = PAGENO.
VSUBNO = SUBNO.
DATAKBN = 1.
VDATAKBN = DATAKBN.
VCODE = ITAB_LIFNR-LIFNR.
VNAME2 = ITAB_LIFNR-NAME2.
VPAYDAT = P_PAY_T.
VGLT0-TSL01 = GLT0-TSL01.
VGLT0-TSL02 = GLT0-TSL02.
VGLT0-TSL03 = GLT0-TSL03.
VGLT0-TSL04 = GLT0-TSL04.
VGLT0-TSL05 = GLT0-TSL05.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT VKINGAKU
VBIKKO VBELNR VGLT0-TSL01 VGLT0-TSL02 VGLT0-TSL03
VGLT0-TSL04 VGLT0-TSL05 INTO VREC SEPARATED BY ','.
CLEAR: BSAK-DMBTR, BSID-DMBTR, BSAD-DMBTR, BSEG-DMBTR, BSIK-DMBTR,
WK_10 , WK_11 , GLT0-TSL05.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 7. " 区分:7
BSID-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSID-DMBTR.
郵送料の出力処理
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 8. " 区分:8
BSAD-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSAD-DMBTR.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 9. " 区分:9
BSEG-DMBTR = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
WK_PAY_AMOUNT = WK_PAY_AMOUNT - BSEG-DMBTR.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 10.
WK_10 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
READ TABLE ITAB_OUTPUT_SUMMARY
WITH KEY LIFNR = ITAB_LIFNR-LIFNR DTYPE = 11.
WK_11 = ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
GLT0-TSL05 = WK_PAY_AMOUNT - WK_10 - WK_11.
WK_PAY_AMOUNT = WK_PAY_AMOUNT - GLT0-TSL05.
VWK_PAY_AMOUNT = WK_PAY_AMOUNT.
VKIN = WK_10.
VTEGA = WK_11.
CONCATENATE VREC VWK_PAY_AMOUNT VKIN VTEGA INTO
VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
WRITE :
VWK_PAY_AMOUNT,
WK_10,
WK_11.
WRITE:/.
BSEG-KOART = 'X'. " フラグ:請求金額を出力
LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR
AND DTYPE = 5. " 区分:5
BSEG-SGTXT = ITAB_OUTPUT_ITEMS-SGTXT. " 明細テキスト
GLT0-KSLVT = ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO. " 金額
TGSBT-GTEXT = ITAB_OUTPUT_ITEMS-GTEXT. BKPF-BELNR = ITAB_OUTPUT_ITEMS-BELNR.
SUBNO = SUBNO + 1.
VSUBNO = SUBNO.
DATAKBN = 2.
VDATAKBN = DATAKBN.
VGLT0-KSLVT = GLT0-KSLVT.
VBIKKO = TGSBT-GTEXT.
VBELNR = BKPF-BELNR.
VSGTXT1 ='請求金額:'.
CLEAR VRECORD.
CONCATENATE VSGTXT1 BSEG-SGTXT INTO VSGTXT.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
WRITE :/ VPAGENO,VSUBNO,VDATAKBN,'請求金額:', VSGTXT, VGLT0-KSLVT,
VBIKKO,VBELNR.
ENDLOOP.
CLEAR: BSEG-SGTXT,GLT0-KSLVT,BKPF-BELNR.
LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR
AND DTYPE = 6. " 区分:6
BSEG-SGTXT = ITAB_OUTPUT_ITEMS-SGTXT. " 明細テキスト
IF ITAB_OUTPUT_ITEMS-SHKZG = CNS_CREDIT. " 金額
GLT0-KSLVT = ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO.
ELSEIF ITAB_OUTPUT_ITEMS-SHKZG = CNS_DEBIT.
GLT0-KSLVT = ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO * -1.
ENDIF.
TGSBT-GTEXT = ITAB_OUTPUT_ITEMS-GTEXT. " 事業領域テキスト
BKPF-BELNR = ITAB_OUTPUT_ITEMS-BELNR. " 伝票番号
SUBNO = SUBNO + 1.
VSUBNO = SUBNO.
DATAKBN = 3.
VDATAKBN = DATAKBN.
VGLT0-KSLVT = GLT0-KSLVT.
VBIKKO = TGSBT-GTEXT.
VBELNR = BKPF-BELNR.
VSGTXT1 ='相殺金額:'.
CLEAR VRECORD.
CONCATENATE VSGTXT1 BSEG-SGTXT INTO VSGTXT.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
concatenate vpageno vsubno vdatakbn
WRITE :/ PAGENO,SUBNO,DATAKBN,'相殺金額',BSEG-SGTXT, GLT0-KSLVT,
TGSBT-GTEXT, BKPF-BELNR.
ENDLOOP.
CLEAR VRECORD.
*Insert empty line.
TRANSFER EMPTYREC TO E_FILE.
DATAKBN = 3.
VDATAKBN = DATAKBN.
SUBNO = SUBNO + 1.
VSUBNO = SUBNO.
VSGTXT ='源泉金額'.
VDMBTR = BSID-DMBTR.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
VDMBTR INTO VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
WRITE :/ PAGENO, SUBNO,DATAKBN, ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
P_PAY_T,'源泉金額', BSID-DMBTR.
CLEAR: VDMBTR, VSGTXT, VRECORD.
SUBNO = SUBNO + 1.
VSUBNO = SUBNO.
VSGTXT = '郵送料'.
VDMBTR = BSAD-DMBTR.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
VDMBTR INTO VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
WRITE :/ PAGENO, SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
P_PAY_T,'郵送料', BSAD-DMBTR.
CLEAR: VDMBTR, VSGTXT, VRECORD.
SUBNO = SUBNO + 1.
VSUBNO = SUBNO.
VSGTXT = '振込み手数料'.
VDMBTR = BSEG-DMBTR.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
VDMBTR INTO VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
CLEAR: VDMBTR, VSGTXT, VRECORD.
WRITE :/ PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
P_PAY_T,'振込み手数料',BSEG-DMBTR.
*その他の支払いの処理
SUBNO = SUBNO + 1.
VSUBNO = SUBNO.
VSGTXT = 'その他の支払い'.
VDMBTR = GLT0-TSL05.
CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
VDMBTR INTO VRECORD SEPARATED BY ','.
TRANSFER VRECORD TO E_FILE.
WRITE :/ PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
P_PAY_T, 'その他の支払い',GLT0-TSL05.
glt0-tsl05.
ULINE.
CLEAR: VREC, VRECORD,VCODE,VNAME2,VPAYDAT,VSGTXT,VSGTXT1,VKINGAKU.
CLEAR: VBIKKO,VBELNR,VDMBTR,VGLT0-KSLVT,VGLT0-TSL01,VGLT0-TSL02.
CLEAR: VGLT0-TSL03,VGLT0-TSL04,VGLT0-TSL05,VKIN,VTEGA,VWK_PAY_AMOUNT.
ENDFORM. -
How to parse data from a text file with no convenient delimiters?
I need to read data from a text file. This file contains one line of data with the repeating pattern "time 00 ADVar2: ___ Height: ____ time 01 ADVar2: ___ Height: ___ ..." I need LabView to parse out the "time" and "height" values, build an array with the values, and graph the correlation on an X&Y plot. Does Labview have an automated way to read to the input data file and parse out the correct values, even without convenient delimiters? Thank you.
You actually do have a convenient delimiter: "time". Thus, you can make an array using that as the delimiter. Only caveat is that the first array element will be empty. Then you can conveniently use the Scan From String function in a for-loop. Something like this:
Message Edited by smercurio_fc on 11-21-2008 03:13 PM
Attachments:
Example_VI.png 9 KB -
How to write from beginning of text file?
Hello all,
All we have to do is to modify just first 2 lines of a 200,000 line files. I can do UTL_FILE.FCOPY to copy from line 3 to end of file and create a new file (FILE1). Now open a new file (say FILE2) and write the modified version of first two lines and then read the file (FILE1) which has rest of the original contents to write to this FILE2. But this process is taking for ever (around 30 minutes).
It would have been easy if I can open FILE1 and just write the first 2 lines. But when I open in append mode I can only write only at the bottom of the file. I tried UTL_FILE.FSEEK but it is not working when the file is opened in Append mode.
Anyone with a solution / suggestion / workaround is greatly appreciated.
Thanks in advance,
ManoharFrancois,
I know the command in Unix to concatenate. There are other easy ways if I can make HOST command work on the application server instead of my local machine. To my surprise both HOST and TEXT_IO are able to work only on my local machine.
I was under the same impression as you are and trying to execute HOST providing Unix commands. Nothing working ... finally when I tried
HOST('echo abc > c:\sample.txt');
it crreated sample.txt on my local machine c:\
Let me know if I am missing something.
Thanks
Manohar -
How to write heading in the xls file with each of the channel in each column?
Dear All,
While writing the data into the xls file through .lvm method I want the Headong for each channel to be include on each of the column, but i dint know how to do this? is this possible in the LabVIEW from any of the file writing method? if yes how can i do that? please help me.........
Thanks,
Nishant DesaiThanks Chilly,
Its a really fantastic idea, and it works for me too, but the thing inside was every time once it writes the heading and then it write the data again after that it wirtes the heading and write the data, but i ve copup with dat and i ve modified the vi which u ve given to me, i am attaching that vi to with this.
wat i ve done is just putting the write to spreadsheet data vi into the while loop and other all are outside the while loop, which makes the heading to write once and data to write continuosly.
Thanks & Regards,
Nishant Desai
Attachments:
Write channel names_yours.vi 25 KB
Write channel names_mine.vi 31 KB -
How to get the content of text file to write in JTextArea?
Hello,
I have text area and File chooser..
i wanna the content of choosed file to be written into text area..
I have this code:
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;
public class Test_Stemmer extends JFrame {
public Test_Stemmer() {
super("Arabic Stemmer..");
setSize(350, 470);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JButton openButton = new JButton("Open");
JButton saveButton = new JButton("Save");
JButton dirButton = new JButton("Pick Dir");
JTextArea ta=new JTextArea("File will be written here", 10, 25);
JTextArea ta2=new JTextArea("Stemmed File will be written here", 10, 25);
final JLabel statusbar =
new JLabel("Output of your selection will go here");
// Create a file chooser that opens up as an Open dialog
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
int option = chooser.showOpenDialog(Test_Stemmer.this);
if (option == JFileChooser.APPROVE_OPTION) {
File[] sf = chooser.getSelectedFiles();
String filelist = "nothing";
if (sf.length > 0) filelist = sf[0].getName();
for (int i = 1; i < sf.length; i++) {
filelist += ", " + sf.getName();
statusbar.setText("You chose " + filelist);
else {
statusbar.setText("You canceled.");
// Create a file chooser that opens up as a Save dialog
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser();
int option = chooser.showSaveDialog(Test_Stemmer.this);
if (option == JFileChooser.APPROVE_OPTION) {
statusbar.setText("You saved " + ((chooser.getSelectedFile()!=null)?
chooser.getSelectedFile().getName():"nothing"));
else {
statusbar.setText("You canceled.");
// Create a file chooser that allows you to pick a directory
// rather than a file
dirButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int option = chooser.showOpenDialog(Test_Stemmer.this);
if (option == JFileChooser.APPROVE_OPTION) {
statusbar.setText("You opened " + ((chooser.getSelectedFile()!=null)?
chooser.getSelectedFile().getName():"nothing"));
else {
statusbar.setText("You canceled.");
c.add(openButton);
c.add(saveButton);
c.add(dirButton);
c.add(statusbar);
c.add(ta);
c.add(ta2);
public static void main(String args[]) {
Test_Stemmer sfc = new Test_Stemmer();
sfc.setVisible(true);
}could you please help me, and tell me what to add or to modify,,
Thank you..realahmed8 wrote:
thanks masijade,
i have filter the file chooser for only text files,
but i still don't know how to use FileReader to put text file content to the text area (ta) ..
please tell me how and where to use it..How? -- See the IO Tutorials on Sun for the FileReader (and I assume you know how to call setText and append in the JTextArea).
Where? -- In the actionPerformed method (better would be a separate thread that is triggered through the actionPerformed method, but that is probably beyond you at the moment), of course.
Give it a try. -
How to write data to an XML file present under application server
frnds: can ne one tell me, how to write data in to a file, which is present under a application server
Ex: i want to write a string data in to a file test.txt which is present under "http://localhost:8080/<some_webapp>/test.txt"
Note:i have deploted a service<some_webapp> under Tomcat/webapps dirVery simple. A servlet can writes to that file if it has the good rights.
In the servlet get (or post) method, use a code like this:
import java.io.*;
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
try {
String filePath = this.getServletContext().getRealPath("/text.txt");//See http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
PrintWriter writer = new PrintWriter (filePath);
//or BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
writer .println("aString");
writer.flush();
writer .close();
} catch (Exception e) {
e.printStackTrace();
}Hope That Helps -
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
-
Write arrays into a text file in different columns at different times
Hi,
I have a problem write data into a text file. I want to write 4 1D arrays into a text file. The problem is that I need to write it at different time and in different column (in other word, not only append the arrays).
Do you have an idea to solve my problem?
Thank youA file is long a linear string of data (text). In order ro insert columns, you need to rewrite the entire file, because colums are interlaced over the entire lenght of the file.
So:
read file into 2D array
insert columns using array operations
write resulting 2D array to file again.
(Only if your colums are guaranteed to be fixed width AND you know the final number of colums, you could write the missing columns as spaces and then overwrite later. Still, it will be painful and inefficient, because column data are not adjacent in the file.)
LabVIEW Champion . Do more with less code and in less time . -
Create and write form output to text file
HI am pretty new to this and have a prob.
I have 10 fields in my form submitting which i need to create and write the form field values into an xml fil..this file is further used for other read write transactions.
Can somebody help creating and writing data into the text file with code (if u have it handy).
Thanks for the help in anticipationFile f = new File("/path/to/output.txt");
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
String inputData = null;
while(true){
inputData = //whatever data you need
bw.write(inputData);
bw.flush();
bw.close();
f.close;
// All this should be in a try{}catch(IOException ioe){} -
How can u insert and retrieve text files in any format using forms6i.
how can u insert and retrieve text files in any format using forms6i.
can u give me an example of an insert statement, let's assume the file is located in the a:drive.
and retrieving the files, i would give the user a list of all the files that are in the database, the user would select one, but what command(or piece of code) would open the file in its apppropriate editor.
e.g .pdf formatted file would open in acrobat.
any help would be appreciated.
Thanks
Hussein Saigerthe filereference class is for downloading and uploading files.
if you want to load xml, use the xml class.
and, if you want to write to an xml file and don't want to use server-side code, wait. -
How to write new line to a File?
How to write new line to a file?
I have a string to be written to a file. the string contains "\n" in it. But why it is not showing the new line in the file.
I have tryed FileWriter class and FileOutputStream class, but none of them works?
any suggestion please...Probably using PrintStream::println() is a portable way.
import java.io.FileOutputStream;
import java.io.PrintStream;
public class NewLine {
public static void main(String[] args) {
try {
PrintStream ps = new PrintStream(new FileOutputStream("foo.txt"));
ps.write("string".getBytes());
ps.println();
ps.close();
} catch (java.io.IOException e) {
e.printStackTrace();
}Regards, -
How copy just line in text file with cat? (SOLVED)
Hi.
How i make to copy just only line in text file with cat?
For example:
[:0.0]
file=/home/Arch/./.wallpaper.png
mode=0
bgcolor=# 0 0 0
I want copy just "/home/Arch/./.wallpaper.png" part.
Actually i want create a shortcut for last wallpaper set from Nitroget, then i put this in SLim background.
Recently i use hsetroot for wallpaper (~/.wallpaper.png) and i create a shortcut in /usr/share/slim/theme/MYTHEME whith ln -s ~/.wallpaper.png /usr/share/slim/theme/MYTHEME/background.png.
I want make a same with Nitrogen.
I now this looks like crazy, but...
Sorry my English.
Last edited by kramerxiita (2008-06-04 16:50:48)moljac024 wrote:
kramerxiita wrote:
moljac024 wrote:How can you make SliM change the background ? You link the theme background to another file ?
Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.
Example:
ln -s mywallpaper.png /usr/share/slim/themes/default/background.png
So, Slim background always is my wallpaper.
So the wallpaper has to be a *.png ?
No, jpg is possible. But when you create a symbolic link, remember put the extension too. If change png to jpg, change a symbolic link extension.
But, remember if slim theme directory have background.png and background.jpg, Slim always choice .png. So, put only one this. -
Write data to multiple text files after specific size
Hello,
I wrote a code that contineously writes data to a text file. The problem is I am running this VI for long time and therefore this text file is being bigger in size e.g. more than 10MB. I want to split writing data in this text file after max 1MB size. Can anyone help ????
thanks in advance.CMW.. wrote:
You could use the "File/Directory Info Function" in the Advanced File VIs and Function palette to check the size. If the file is too big. close it and create a new one.
I would use the Get File Position since this won't cause Windows to have to do so much. Assuming you are just writing and not setting the file position manually, this will return the size of the file in bytes (file position will always be at the end of the file).
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Maybe you are looking for
-
Combine files to PDF and selecting files one at a time - Adobe CreatePDF online application
Are you able to select up to 10 files at one time through the "select files" browser window? The instructions at https://www.acrobat.com/createpdf/en/merge-combine-pdf-files-online.html seem to indicate that you are able to select up to 10 items and
-
How to show different value, other than whatever from database in a Field
I have a repeatating frame (corresponding to one query). there are 6 fields (columns) in th RF. Now say in one of the column the database values are like 1,2,3,4 etc.. I want to show 'ASSIGNED' corresponding to value 1, INPROGRESS corresponding to va
-
Multiple file receiver scenario
Hi, I am carrying on a file to multiple files scenario(3 in no). The scenario is simple and it's just that some fields of <b>Sender File</b> are mapping to <b>Receiver Files</b> There are no conditional routing, BPM etc. I have done all the IR part
-
I was wondering, can iweb templates web site?
-
What's the quickest way to find all calls to some PL/SQL package?
Here's my situation: I have a large application (>100 pages) which has multiple calls to a PL/SQL package procedure X.Y occurring in various processes, conditions, etc on an unknown set of pages. The procedure is being moved to package Z, so I want t