J2ME write into a file

hello,
I succeed to read a file which at the address "http://localhost:8004/hello.txt" but I don't succeed to write into a file which the same address
How write into a file, in a midlet?

An example using ASP:
Set fs=server.CreateObject("Scripting.FileSystemObject")
If fs.FileExists(Request.ServerVariables("APPL_PHYSICAL_PATH") & relative_path_and_file_name)=false then
     Set file=fs.CreateTextFile(Request.ServerVariables("APPL_PHYSICAL_PATH") & relative_path_and_file_name,true)
Else
     Set file=fs.OpenTextFile(Request.ServerVariables("APPL_PHYSICAL_PATH") & relative_path_and_file_name,8) ' 8 is for append, 2 for overwriting
End If
file.WriteLine(some_text)
file.close

Similar Messages

  • HELP!!!!!! - How to write into a file?

    How to write into a file?
    I want to make a script that will connect(not enter) to my website[for example, www.vasa.com] every time i connect to the internet.
    Now i have 3 problems:
    1. i dont know how to write into a file
    2. i dont know how to make it connect to my 'server' without entering the website
    3. i dont know what file to write it to
    so if someone can help me, please do.

    Well, how about RTFM?? In this case that can be found here:
    http://developer.java.sun.com/developer/onlineTraining/
    BTW - these things have been asked azillion times, search the forum.

  • How to read from one file and write into another file?

    Hi,
    I am trying to read a File and write into another file.This is the code that i am using.But what happens is last line is only getting written..How to resolve this.the code is as follows,
    public String get() {
         FileReader fr;
         try {
              fr = new FileReader(f);
              String str;
              BufferedReader br = new BufferedReader(fr);
              try {
                   while((str= br.readLine())!=null){
                   generate=str;     
              } catch (IOException e1) {
                   e1.printStackTrace();
              } }catch (FileNotFoundException e) {
                   e.printStackTrace();
         return generate;
    where generate is a string declared globally.
    how to go about it?
    Thanks for your reply in advance

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • Some Doubts in write into spreadsheet file function

    hi,
    i have some problem with writing the values into excel file...if \ found then the values after will write the values in next rows...
    for eg. if i give 78/58\46/86 then i will write as in picture i hav attached..
    Attachments:
    Mod 1.vi ‏23 KB
    Untitled.png ‏135 KB

    The Write to Spreadsheet File is not the same as writing to Excel -- for that, you should use the Report Generation Toolkit (and there have been a number of posts here, as well as examples that ship with LabVIEW).
    That being said, it is not clear (a) what you are trying to do, and (b) what is (or is not) happening.  The image you attached looks OK ...

  • Read and write into csv file using procedure

    I would like to read a particular column value from csv file(which will have many columns) using procedure and for that value I have to retrieve some more values from database table and have to append into same csv file.
    can someone help me?
    Thanks
    Edited by: 1002478 on Apr 25, 2013 5:52 AM
    Edited by: 1002478 on Apr 25, 2013 5:55 AM

    1002478 wrote:
    thanks for your reply.
    Using UTL_FILE i'm able to read csv file. I'm stuck up in appending some more columns to same csvYou'll struggle to append data to an existing CSV.
    You'd be better to read the data from one CSV, and create another CSV using that data, and the extra data you want, and then when finished, delete the original file and rename the new file to the old filename.
    You should be able to do that using External Tables to read the source file (easier than using UTL_FILE) and UTL_FILE to write the new file.

  • How to get sql query data and write into csv file?

    I am writing to seek help, in how can I create bat. script which can execute the following logic:
    connection to the database
    run sql query
    create CSV file
    output query data, into CSV file
    save the CSV file
    osql
    -S 84.18.111.111
    -U adw
    -P rem
    -i "c:\query.sql"
    send ""
    sed -e 's/,\s\+/,/g' MCI_04Dec2014.csv > localNoSpaces.csv
    -o "c:\MCI_04Dec2014.csv"
    This what i have so far, and I am little struggling with the logic after creating CSV file. I am unable to get the above script to work, please advice further, where I may be going wrong. 
    Can you create if statement logic within window's script, to check for null parameters or data feeds?
    Any hints would be most appreciated. 

    Thank you for your reply. 
    Apology for posting the code irrelevant to the forum, as I am still novice scripting user.  
    My goal is to create window's script which can compute the above logic and send the final output file (csv), to FTP folder. 
    Can this logic be implemented via bat. script, if so, is there a example or tutorial i could follow, in order to achieve my task. 
    Any help would be much appreciated. 

  • How we write into properties file using get class method

    Hi
    I want to set some value into properties file using given code
    can any one please tell me how i can do this.
    property file
    setting.properties
    Name     =     abc
    and code I use is
    java.io.InputStream oInputStream = this.getClass().getResourceAsStream("Setting.properties");
                   Properties obj = new Properties();
                   obj.load(oInputStream);
                   String myName = obj.getProperty("Name");
                   System.out.println("myName :"+myName);
                   obj.setProperty("Name","def");
                   FileOutputStream oOutput= new FileOutputStream("Setting.properties");
                   obj.store(oOutput, "");
    thanks.

    You can't.
    If you have properties that change dynamically, you should not be using a properties file that sits in the classpath, you should be using Preferences, or a properties file that sits in some application or possibly even user directory, but not one in the classpath. The proper way to do this, would be to have a properties file in your jar (or otherwise in your classpath) that contains the defaults, and another one outside of the classpath in one of the twwo above mentioned areas, then, you read the default one only if the other doesn't exist, or you read the default one first, then read the other overwriting the values from the defaults.
    Don't forget to save the properties again (right after loading if you loaded, or always load, the defaults) after every change.

  • Write into existing file with "write to text file"

    Hi all,
     I have a text file that contains several lines of data (text). Now I would like to replace the first three lines with text coming from a string array.
    My approach is shown in WriteToFile.vi that is attached.
    When I am executing this vi (with an empty file), everything seems to be working fine in the first place.
    The file will contain the following text:
    oneoneone
    twotwotwo
    threethreethree
    Now, when the third element in the array is shortened (lets say to "threethr") before execution,  the file will contain  the following text:
    (the file was not emptied before execution)
    oneoneone
    twotwotwo
    threethr
    three
    How can I avoid the last line being written? I have made many tests and I could not find a solution.
    One more example:
    Lets say we have an existing file, inside this file is:
    oneoneone
    twotwotwo
    three
    fourfourfour
    Now I would like to overwrite line three with "threethreethree". Therefore I execute my vi as shown in the attachment.
    What I get as a result is:
    oneoneone
    twotwotwo
    threethreethree
    ur
    So, the text in line four, which should not be touched, is "ur" instead of "fourfourfour".
    Any idea to solve this problem?
    What I basically need is replacing a line of a text file in a conveinient way.
    Thanks,
    Holger
    LV 8.5.1
    Attachments:
    WriteToFile1.jpg ‏17 KB
    WriteToFile.vi ‏11 KB

    The remaining fourth line is there because the third line has a <nl> at the end. You have not emptied the file so the rest of the file will be kept. This is because your line is shorter.
    In the scond example the third line is longer and it will overwrite the beginning of the fourth line.
    Files aren't organized in lines they are oganized in bytes. And what you write are bytes to the file even with text files.
    Replacing a single line in a file is done by reading the file line by line. All unchanged lines are written to a temporary file and the line with the new text will be written instead of the original line to the temporary file. When the writting is done rename the original file, then rename the new file into the original file and then delete the renamed original file.
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Write into XML file

    Hi,
    I have a xml file uploaded to the Document Management. I write a script to prompt the caller to leave a recording. I want to save the recording file name into the xml file. How do I do that? How do I append the recording file name into the existing xml file? Or I need to create a new one?
    Attached is the xml file that has been uploaded to the Document Management.
    Please help.
    Thanks & regards,
    How Yee

    To get you started:
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPDOM7.html#65002
    Shows you how to construct a XML Document in memory, so you can put the user data into a XML Document.
    Use a Transformer (http://java.sun.com/j2se/1.4/docs/api/index.html) to write out your XML document to a file.

  • How to write into a file from an applet?

    Dear,
    I made an applet and I want to create a file in a machine. I tried many way but it not work.
    Here is the code:
    URL url = "http://hostname/filename.txt;
    URLConnection con = url.openConnection();
    OutputStream out = con.getOutputStream();
    out.write(data);
    out.flush();
    out.close();
    Please help me resolve it.
    Thanks.
    Khai

    URL url = new URL("http://hostname/filename.txt);
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(url.openStream()));
    out.write("data");

  • Append data into the file in application server

    Hi Friends,
    I have an issue where i have a job which has three different stepst for same program. If i run the job the program will create a file in the application server and append the other two steps in the same file without overwriting the file or creating a new file.
    My problem is like its creating three different files in application server for that particular job since it has three steps . Its not appending into one particular file .
    I am using the FM 'Z_INTERFACE_FILE_WRITE' where i have used the pi_append in the exportng parameter . ITs working when i specify the file in local system. It is appending correctly when i run the report normally to apppend into local system.
    But when i schedule a job to append the file in application server its creating three different files.
    Kindly help me if anyone is aware of this issue
    Thanks in advance
    Kishore

    Hi,
    Please use open dataset to write and append files.Please check the logic of Z FM which you are using .
    To open and write into a file  use
    OPEN DATASET FNAME FOR OUTPUT.
    To append data into existing file use
    OPEN DATASET FNAME FOR APPENDING.
    To write into file:
    v_file = file path on application server
      OPEN DATASET v_file FOR output.
      IF sy-subrc NE 0.
    write:/ 'error opening file'.
      ELSE.
       TRANSFER data TO v_file.
      ENDIF.
    CLOSE DATASET v_file.
    For appending :
    OPEN DATASET v_file fOR APPENDING.(file is opened for appending data  position is set to the end of the file).
    Thanks and Regards,
    P.Bharadwaj

  • Changes in Microsoft Active Directory Services into a file

    I am in need of sample code to capture changes in Active Directory services into a flat file.
    Here is my requirement:
    I would like to capture user information changes from the Active directory server into a flat file.
    For an example, When a user is newly created in Actives Directory Server, I need to Capture that user info and write into a flat file. Similarly for update and delete user in Activer Directory server, i need to capture the changes and write into a file.
    Would appreciate, if any could help me on this
    Thanks in advance
    Thanks
    Kumar

    Refer to:
    JNDI, Active Directory & Persistent Searches (part 1) http://forum.java.sun.com/thread.jspa?threadID=578338&tstart=200
    There was another topic that I posted called JNDI, Active Directory and Persistent Searches (part 2) in which I described teh LDAPNotification Control.
    It had the following URL http://forum.java.sun.com/thread.jspa?threadID=578342&tstart=200 however it seems as though I have suffered another case of the forum losing my posts.

  • Can't write to a file using File class

    hi every body
    I wanna write into a file for logging purpose, but I always
    got an error when I write to the file ...
    the code is:
    if(!logFile.isOpen)
    logFile.open("text", "write")
    var date = new Date();
    if(logFile.canWrite){
    trace(">> I will write ...");
    var message = "TIME >> " + date.getDate().toString() +
    " : ERROR CODE >> " + infoObject.code + " : LINE NO >>
    " + infoObject.lineno.toString();
    logFile.write(message);
    logFile.flush();
    logFile.close();
    I got an error says: File operation writeln failed
    and also may say: File operation flush failed
    thanx

    First off, don't use finalize(). It is never guaranteed to actually run.
    Just add a cleanup() method to your Account class that flushes and closes the writer; and call it before you exit main().
    Now, as for your Date problem
    java.util.Date certainly does have a no-args constructor.
    java.sql.Date does not.
    Make sure you aren't getting a name collision. (Hint: If you're doing import java.foo.* Stop Doing That. just import the classes you need)

  • Hi am trying to save Data into a write to measurement file vi using a NI PXI 1042Q with a real time mode but it is not working but when i run it with uploading it into the PXI it save in to the file

    Hi am trying to save Data into a write to measurement file vi using a NI PXI 1042Q and DAQ NI PXI-6229 with a real time mode but it is not working but when i run it without uploading it into the PXI it save in to the file please find attached my vi
    Attachments:
    PWMs.vi ‏130 KB

     other problem is that the channel DAQmx only works at real time mode not on stand alone vi using Labview 8.2 and Real time 8.2

  • How to write the output of a mapping into a file (OWB10.2

    Hi
    I am using Oracle 10.2.0.1 version of OWB.
    the task is to write the output of a mapping into a File (Flat File).
    Please help me out!
    Regards
    Abi

    Hi,
    Create the file format thru OWB and mention the location in OWB. Deploy the file and it will be ready to use for target load. Make sure the connection to the target loc is available.
    Regards
    Bharadwaj Hari

Maybe you are looking for

  • Generation of XML Schema according to Table structure

    Hi all !, I am extracting the data from the database and creating an XML file with corresponding data elements. I can do it successfully. Is there any way to generate the XML schema file based on the structure of the Table, dynamically? Please help.

  • Communication channel Monitoring

    Hi, we are in Pi 7.1 SP 8 In communication channel monitoring under Cluster Node Details for Channel CC_XXXX i can see two nodes and both having same cluster node ID and short Log. one node in error and other node is success do i have to do any setti

  • Can't update itunes my old version is newer than the release today

    I have had this problem twice now. And it is really starting to get on my nerves. Every time apple puts out an update for itunes it states that the current one on my computer is newwer than the version that is was just released 2 days ago (today marc

  • Time valuation with and without clock times --- Plzz help

    hi experts Please help me by explaining the following. 1) Please explain me the differnces between time valuation with    clock times(T555Z) and time evluation without clock time(T555Y). 2) Please explain the differences in time types and processing

  • The email on my apple ID password box isn't mine. How do I change it back?

    When I go to pull up an app, the little blue box pops up and asks for your apple password. The apple ID above where the password is entered is not mine. I noticed this a couple days ago. How do I change that to match my actual apple ID?