How to Save a text file in the server?
hello
i just want to save an text file in the server.
My idea is to load an xml text file maybe make some changes
and then save it back to the server, so i can avoid all the
database/php work because i know nothing about it.
thank you
hello
i just want to save an text file in the server.
My idea is to load an xml text file maybe make some changes
and then save it back to the server, so i can avoid all the
database/php work because i know nothing about it.
thank you
Similar Messages
-
How to download a text file from the server
hi everyone,
can anyone tell me how to download and read a text file from the server and saved in into resource folder.
with regards
pallaviits really easy
To read from server, use something like:
HttpConnection connector = null;
InputStream inp_stream = null;
OutputStream out_stream = null;
void CloseConnection()
if(inp_stream!=null)inp_stream.close();
inp_stream=null;
if(out_stream!=null)out_stream.close();
out_stream=null;
connector.close();
connector = null;
public void getResponse(String URL,String params)
try
if(connector==null)connector = (HttpConnection)Connector.open(URL);//URL of your text file / php script
connector.setRequestMethod(HttpConnection.POST);
connector.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.1");
connector.setRequestProperty("content-type", "application/x-www-form-urlencoded");
//connector.setRequestProperty("charset","windows-1251");
//*** If you need to send ("arg1=value&arg2=value") arguments to script use this:
out_stream = connector.openOutputStream();
byte postmsg[] = params.getBytes();
out_stream.write(postmsg);
int rc = connector.getResponseCode();//in any case here connection will be opened & closed
if (rc != HttpConnection.HTTP_OK)
CloseConnection();
throw new IOException("HTTP response code: " + rc);
inp_stream = connector.openInputStream();
int pack_len = inp_stream.available();
byte answ[]=new byte[pack_len];
inp_stream.read(answ);
CloseConnection();
ProcAnswer(answ);//process received data
catch(Exception ex)
System.err.println("ERROR IN getResponse(): "+ex);
} And you can read from resource file like
public void loadFile(String filename)
DataInputStream dis = new DataInputStream(getClass().getResourceAsStream("/"+filename));
String str="";
try
while (true)
ch = dis.read();//read character
if(ch=='\r')continue;//if file made in windows
if(ch=='\n' || ch==-1)//end of line or end of file
if(str.length()==0)continue;//if empty line
//do some thing with "str"
if(ch==-1)break;//it was last line
str="";//next line
continue;
str+=(char)ch;
dis.close();
catch (Exception e)
System.err.println("ERROR in loadFile() " + e);
}Welcome! =)
Edited by: MorskoyZmey on Aug 14, 2008 3:40 AM -
HOW TO SAVE A TEXT FILE ON AL11
HOW CAN WE SAVE A TEXT FILE ON THE APPLICATION SERVER AL11 WHICH IS ON THE DESKTOP OR ANY DRIVES.
CAN SOME ONE GIVE ME THE STEP BY STEP PRCEDURE
REWARDS IF USEFULHi,
Use Tcode CG3Z to upload files to application server and use tocde CG3Y to download file to your desktop.
Reward points if helpful.
Regards,
CS. -
HOw to create a text file in the given path and delete it after the use?
Hi all,
I am trying to create a text file at the given path and delete the created file after the use.
I am using following code.:
import java.io.*;
// write binary data as characters
public class RanIO {
public static void main(String f[])
// First illustrate append
String lineSep = "\n";
try {
File temp= new File("C:/Ash","cute.txt");
boolean ch=temp.createNewFile();
if(ch)
System.out.println("file created");
else
System.out.println("file Not created");
//writing to file
/* PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
p.print("Emp NO");
p.close();*/
// Open fileWriter in append mode
FileWriter fos = new FileWriter(temp, true);
BufferedWriter bw = new BufferedWriter(fos);
PrintWriter pw = new PrintWriter(fos);
double d=550;
// lineSep = System.getProperty("line.separator");
pw.print("Hello");
//pw.print( lineSep );
pw.print( d );
pw.close();
boolean det=temp.delete();
if(det)
System.out.println("File deleted");
else
System.out.println("File not deleted");
} catch (IOException ioe)
System.out.println( "Append IO error:" + ioe );
My problem:
1)
I am not able to write to the file. I want to know, where i am going wrong.
It is giving error message like
"Canot resolve Symbol: temp,"
But, FileWriter Constructor should accept a File type parameter.
here temp is a file parameter.
If i am not using file=new file();
i can't delete the file after the use. i.e if i use
PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
how can i delete cute.txt after the use?
2)
I am not able to write to the text file. file is created but, a blank file.
"Hello" is not written into the text file.
can anyone help me in this regard
Thanks in advance
AshviniThank you Ram,
But, i want to create a text file in Append mode.
for that i used
FileWriter fos = new FileWriter(temp,true); But, it is not accepting FileWriter constructor in
this format. if i use
FileWriter fos = new
FileWriter("c:/ash/cute.txt",true); it works fine. !!!!!Here's the javadoc
public FileWriter(File file,
boolean append)
throws IOExceptionConstructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
Parameters:
file - a File object to write to
append - if true, then bytes will be written to the end of the file rather than the beginning
Throws:
IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
Since:
1.4
Are you using jdk.13 or lower ?
>
ONe more doubt, Does flush method deletes a file?
if not, then i need to use
File temp=new File("c:/ash/cute.txt");
FileWriter fos = new FileWriter(temp,true); //which
is again a problem
if(temp.delete())
out.println("File is deleted");
}I don't know whether i am taking it wrong ! or
anything wrong with my coding ! but, after creating
and writing data into a text file. I must delete it
as it contains confidential informations.
Regards,
Thanks.'flush' writes to a file immediately. Else you should explicitly call 'flush' to write contents from buffer to underlying source.
javadoc again
PrintWriter
public PrintWriter(Writer out,
boolean autoFlush)Create a new PrintWriter.
Parameters:
out - A character-output stream
autoFlush - A boolean; if true, the println, printf, or format methods will flush the output buffer
cheers,
ram.
Question; What do you gain by opening a file, writing to it and deleting it in the same program ? -
How to save an Excel file to the desk top
How can I save an Excel file to the desk top?
Hi Tim!
There's a whole bunch of entries that come up when I open terminal and key in the command you gave; here's what is shown:
Davids-Mac-Pro:Desktop pdf3$ ls -ale ~
total 38384
drwxrwxrwx+ 41 pdf3 admin 1394 Nov 2 09:12 .
0: group:everyone deny delete
drwxr-xr-x 6 root admin 204 Sep 19 14:58 ..
-rw-rw-rw- 1 pdf3 admin 3 Jan 24 2012 .CFUserTextEncoding
-rw-rw-rw-@ 1 pdf3 admin 39940 Nov 3 10:48 .DS_Store
drwx------ 2 pdf3 admin 68 Nov 6 09:02 .Trash
drwxrwxrwx 3 pdf3 admin 102 Feb 1 2012 .adobe
-rw-rw-rw- 1 pdf3 admin 302 Nov 6 09:20 .bash_history
drwxrwxrwx 6 pdf3 admin 204 Dec 31 2013 .blurb
drwxrwxrwx 3 pdf3 admin 102 Oct 21 2012 .config
drwxrwxrwx 3 pdf3 admin 102 Jan 27 2012 .cups
drwx------ 7 pdf3 admin 238 Jul 26 20:36 .dropbox
drwxr-xr-x 4 pdf3 admin 136 Dec 7 2013 .fontconfig
drwxrwxrwx 3 pdf3 admin 102 Mar 17 2012 .nchsoftware
-rw-rw-rw-@ 1 pdf3 admin 17 Oct 21 2012 .vbftpxmn
-rw-r--r--@ 1 pdf3 admin 1315548 Sep 3 2013 2014 Bellevue SW Collection Contract 04 15 2013 draft for RFP.pdf
drwxrwxrwx 2 pdf3 admin 68 Sep 21 11:04 Applications
-rw-r--r--@ 1 pdf3 admin 326665 Aug 30 2013 Bellevue Reliability Report 2012 042613 Final-1.pdf
-rw-r--r-- 1 pdf3 admin 6737 Sep 25 2013 Bellevue Reliability Report 2012 042613 Final.txt
-rw-r--r--@ 1 pdf3 admin 35892 Oct 30 22:15 Bellevue Utility Bills, 2015-16.xlsx
drwxrwxrwx@ 3 pdf3 admin 102 Aug 16 14:52 Burn Folder.fpbf
-rw-rw-rw-@ 1 pdf3 admin 25989 Jun 18 2012 Concerns Expressed to City of Bellevue Regarding Approval of.pdf
-rw-r--r--@ 1 pdf3 admin 165592 Sep 5 2013 David's Autobiography copy.pdf
-rw-r--r--@ 1 pdf3 staff 34836 Jul 26 21:21 Deck Repair, 2014.xlsx
drwx---rwx@ 35 pdf3 staff 1190 Nov 5 12:54 Desktop
0: group:admin allow list,add_file,search,add_subdirectory,readattr,writeattr,readextattr,writeextat tr,readsecurity
-rw-r--r--@ 1 pdf3 admin 111548 Nov 15 2013 Document2.pdf
drwx------+ 18 pdf3 staff 612 Nov 5 11:43 Documents
0: group:everyone deny delete
drwx------+ 494 pdf3 staff 16796 Nov 2 22:09 Downloads
0: group:everyone deny delete
drwxr-xr-x 2 pdf3 admin 68 Nov 1 11:54 Excel Work Book
drwxr-xr-x 2 pdf3 admin 68 Oct 31 20:42 Excel Workbooks
-rw-rw-rw-@ 1 pdf3 admin 16862554 May 29 2012 Group Shot.psd
drwx------@ 53 pdf3 staff 1802 Sep 19 15:17 Library
0: group:everyone deny delete
drwx------+ 6 pdf3 staff 204 May 28 2013 Movies
0: group:everyone deny delete
drwx------+ 8 pdf3 staff 272 Feb 24 2014 Music
0: group:everyone deny delete
-rw-rw-rw-@ 1 pdf3 admin 117444 Jul 21 2008 P6M-2 In Close copy.jpg
-rw-r--r--@ 1 pdf3 admin 46473 Aug 16 14:50 PW-M-1 Overlay Budget.xlsx
drwx------+ 65 pdf3 staff 2210 Nov 5 11:43 Pictures
0: group:everyone deny delete
drwxr-xr-x+ 5 pdf3 staff 170 Jan 24 2012 Public
0: group:everyone deny delete
drwxr-xr-x 6 pdf3 admin 204 Mar 10 2014 Sound Transit Bel-Red Cost Estimate
drwxr-xr-x 34 pdf3 admin 1156 Sep 21 09:24 WW II Songs & Opera #1
-rw-r--r--@ 1 pdf3 admin 172859 Feb 25 2014 photo 1.JPG
-rw-r--r--@ 1 pdf3 admin 172859 Feb 25 2014 photo 3.JPG
Davids-Mac-Pro:Desktop pdf3$
I have no idea what all this stuff means, but I've done a 'disk verify' for both my drives, and the results indicated they were both 'OK'.Dave P. -
How to read two text files using the Read from spreadsheet.vi and then plot it
I need to read two text files using the read from spreadsheet function and then plot these files over time.
The file with the .res extention is the RMS values (dt and df) and the second file contains the amplitude of a frequency spectrum.
I really appreciate any help..thanks
Attachments:
RMS.txt 1 KB
FREQUENCY.txt 1 KBFrom NI Example Finder:
Write to Text File.vi
Read from Text File.vi
Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp -
How to download a pdf file from the server from an strut application?
Hi,
I wan to download a pdf file from the server side to local system. Please help me how i use the down load option.Read up on the Struts download action [1].
And next time, please post in the relevant forum, one of the web-tier ones [2].
[1] http://wiki.apache.org/struts/StrutsFileDownload
[2] http://forum.java.sun.com/category.jspa?categoryID=20
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
---------------------------------------------------------------- -
How to read an xml file on the server?
Hi all,
we need to read an XML file which will be on the appplication server (visible using the transaction AL11).
We will use the transaction CG3Z in order to upload the file to the server.
When we try to open it using the instruction OPEN DATASET we have a dump. Which way must we use to open an xml file in this case?
Thanks for your help.
DavidHi
With open dataset you can open any file on the application server. So it should be working, but maybe you are looking for:
CALL TRANSFORMATION my_transformation
SOURCE XML xml_string
RESULT ROOT1 = field1
ROOT2 = field2.
Best regards,
Guido Koopmann -
How to delete a text file in the HP cloud
I had a text file that was created through a text (notpad type app ) on my kindle fire. I sent it to my HP printer using the Eprint app which worked great. I deleted the file from the notepad app but it still shows up in my HP cloud. How do I go about deleting it from my Eprint files ??
Hi there, can you clarify what you mean by "How do I go about deleting it from my Eprint files ??"
If its the notification message from within the ePrint app itself, then it is only a notification and a copy of the file does not get stored in the app.
Best.
If my reply helped you, feel free to click on the Kudos button (hover over the "thumbs up").
If my reply solved your problem please click on the Accepted Solution button so other Forum users may benefit from viewing the post.
I am an HP employee. -
How can I upload a file to the server where I save the Java Web Start Files
Hello,
Does anyone knows how to upload a file to the directory where I save the JAR files through the Java Web Start program. Thanks youftp
-
How to save a .csv file to database server
Hi every body,
I need to upload a .csv file from the client machine and save it to a directory in a database sever.
I could do the uploading part. Can anyone tell me how to save the file?
Another option is save the file as a CLOB in a database column. But I'm not aware of doing that too.
Please guide me.
Thanks in advance.
Surangi.See Steve Muench's Not Yet Documented Example #85 at http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html#85. While this is for 10.1.3, this is still relevant for 11g. Steve's example is for uploading to a BLOB - same thing for a CLOB. Once your data is in the database, you can use the DBMS_LOB package to write the file to a directory on the database server, if you like.
Also the Developers Guide is your friend - Chapter 9.9 in the Fusion Web User Interface Developers Guide for Oracle ADF 11g, or 19.6 in the ADF Developers Guide for Forms/4GL Developers for JDeveloper 10.1.3. -
How to save 150MB BLOB file in the database(SQL server)?
Dear experts,
I have written some code to save BLOB into a MS SQLserver7.0 database as follows:
PreparedStatement ps=connection.prepareStatement("INSERT INTO jdbctest" + "(id, content, image) VALUES (?,?,?)");
ps.setString(1,"2");
ps.setString(2,"L11.avi");
ps.setObject(3,data);
It works for upto 12MB but for files that are as big as 150MB I always get an SQLException as follows,
"Exception in thread "main" java.lang.OutOfMemoryError
<<no stack trace available>>" .
The SQLserver7.0 database is running on NT server 4. The client machine is SGI UNIX. I'm using i-net JDBC driver.
It seems I should break the BLOB into chunks before saving into SQLserver but I don't know how to do it.
Can someone please advise?
THANKS!
YuCould you tell me more about it? Thanks.Depends on the application.
For example for internal use you can set up a shared drive and then everyone gets a mapped read only access to it. Then you use a direct drive reference.
For external, or just wider internal distribution, you could set up a ftp server. Then the address is just an ftp address.
I believe there are other variations which can be implemented via browsers and support by the websever. For example loading a word doc via the browser.
The advantage to the above is that you don't have to push it into the database and it allows for some more flexible storage alternatives. The disadvantages are all the things you might want a database for - like concurrency checking and a single source. -
Save an xml file in the server
Soory Something happen and it post 2 time. this is the same post as below......... i cant remove it
The error.log file is in <Apache installation folder>/logs. For example, my Windows-based installation has its logs in D:\Program Files\Apache Software Foundation\Apache2.2\logs\
I ran your example, and the error ocurred at xmldoc(), so I suspect I am missing an extension library somewhere. I don't know how your PHP is configured, so I can offer you no help. If you can confirm the error on your side, and unless someone else has more insight, I think you might want to ask in a PHP forum. -
Writing from a BLOB to a FIle on the Server
I need to be able to save the data from a BLOB column to an external file on the server, preferably in a temporary directory. Afterwards I will add a header to the file and send to the web client. I believe I know how to add the header. However, everything I have read in DBMS_LOB or UTIL_FILE describes saving a BFILE or CLOB to a BLOB, but not the reverse. Can you save from a BLOB to an external file on the server? The processing must be done on the Server.
I have been able to select TEXT from a VARCHAR column and save to a file on the server but unable to select a BLOB and save to the file.
Thank you for your help,UTL_FILE would be the correct thing to use, but I seem to recall that it didn't work for binary files. It apparently adds CR LF data into the files when written. I am not sure if this has changed recently or not. You might try posting in the database or PL/SQL forum about UTL_FILE.
-
Problem with saving data in text file in Application server
Hello Experts,
I am trying to save a text file in application server.When I text file have less that 60000 (i.e 59999) records, it saves the file successfully, but if records in text file (saved in application server) is more than 60000 (i.e 60002), it creates a new file at the 60000th record with the continued records.
Can anyone please advise, why it is creating a new file if records are more that 60000. I tested it with 59000 records in my internal table and it is working fine. I have not given any restriction in my program to create a new file if records are more than 60000.
The logic I implemented is the following:
*Open file
open dataset g_accnt_file for output in text mode encoding utf-8.
if sy-subrc = 0.
clear g_header_record.
*Building header record for Accounting Validation file
concatenate gc_hdr_desc
gc_filetype
gc_sequence
gc_idntf_refresh
gc_cmpny_idntf
gc_accnt_id
sy-datum
sy-uzeit
gc_linde_group
sy-sysid
gc_not_used into g_header_record separated by
gc_deliminator.
transfer g_header_record to g_accnt_file.
*Move Cost center data to file to create a detail record for Accounting
*Validation file
loop at gt_csks into gs_csks.
*Remove leading Zeros
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = gs_csks-kostl
importing
output = gs_csks-kostl.
* Overlay gs_csks-kostl with space.
* SHIFT gs_csks-kostl RIGHT DELETING TRAILING gc_space.
*Prepare Cost Centre String
perform prepare_costcentre_string.
*Prepare detail record with Company Code & Cost Centre
perform prepare_detail_record.
clear:g_detail_record,gs_csks,g_coa.
endloop.
*Move Order data to file to create a detail record for Accounting
*Validation file
loop at gt_aufk into gs_aufk.
*Remove leading Zeros
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = gs_aufk-aufnr
importing
output = gs_aufk-aufnr.
* SHIFT gs_aufk-aufnr RIGHT DELETING TRAILING gc_space.
*Prepare Order String
perform prepare_order_string.
*Prepare detail record with Company Code & Order
perform prepare_detail_record.
clear:g_detail_record,gs_aufk,g_coa.
endloop.
*Move WBS data to file to create a detail record for Accounting
*Validation file
loop at gt_prps into gs_prps.
call function 'CONVERSION_EXIT_ABPSP_OUTPUT'
exporting
input = gs_prps-pspnr
importing
output = g_wbs_element.
* SHIFT g_wbs_element RIGHT DELETING TRAILING gc_space.
*Prepare WBS Element String
perform prepare_wbs_string.
*Prepare detail record with Company Code & WBS Element
perform prepare_detail_record.
clear:g_detail_record,gs_prps,g_coa.
endloop.
*Building trailer record for Accounting Validation file which will
*contain the total number of detail records in file
concatenate gc_trail_desc
g_total_count
into g_trailer_record
separated by gc_deliminator.
transfer g_trailer_record to g_accnt_file.
*Close file
close dataset g_accnt_file.
if sy-subrc = 0.
message s036(/lig/fi).
endif.
endif.
endform. " SELECT_DATA
Edited by: Matt on Sep 30, 2010 11:02 AM - added tagsHi Pankaj,
Can u check the concatenate statement with one more data. Check the no of lines for a single file.
concatenate gc_hdr_desc
gc_filetype
gc_sequence
gc_idntf_refresh
gc_cmpny_idntf
gc_accnt_id
sy-datum
sy-uzeit
gc_linde_group
sy-sysid
sy-subrc
gc_not_used into g_header_record separated by
gc_deliminator.
Regards,
Amitava
Maybe you are looking for
-
How can I switch my Apple Account from UK store to Canada Store?
Each time I need to update something on my iPad, a dialogue appears saying I need to switch to Canadian store, I do I get this done please?
-
HT201269 My iPhone 5 isn't being recognized by my laptop anymore?
My iPhone 5 isn't being recognized by my laptop since I upgraded from the 4S. Any ideas?
-
Hi, I'm brand new to writing FrameScript. I'm looking for example scripts that I can piece together or perhaps you can give me a quote for your cost to write the script for me. Here is a description of basically what needs doing. We have .book fil
-
HT1660 How do I load my itune library files from to another computer?
I have a new computer and am trying to find my itunes files. How do I do that?
-
Why does the character size keep changing to extreme small on the home page?
With the new Firefox downloaded the character type changes to extremely small print every time I go away from the home page. I then have to reset it to larger print. With old Firefox the print size remained as I set it all the time.