Need to an OutputStream or Writer to write in a file

Hello,
I my java class, I need to an OutputStream or a Writer to write in a file. The problem is that I am in a webapp.
To get an inputStream, I use this :
InputStream is = this.getClass().getResourceAsStream("RELATIVE_PATH_IN_WEBAPP");
But it doesn't exist a correspondance for the outputstream.
With this code :
Writer writer = new FileWriter("RELATIVE�_PATH_IN_WEBAPP");
I cannot find the file because it looks for my application server relative path.

Ok but I think it doesn't help me.
To explain : I have a servlet that calls a service in a Java class :
public class MyServlet extends HttpServlet{
public void init(){
MyService service = new MyService();
String file = "RELATIVE_PATH_IN_WEBAPP//myfile.xml";
service.createFile(file);
In MyService class :
public void createFile(String file){
XMLWriter writer = new XMLWriter( //dom4j API
new FileWriter(file) );
writer.write( document );
But this doesn't looks for my file in the relative path of the webapp.

Similar Messages

  • How Do I write an XML file using Java?

    Hello there!! to everyone reading my post.
    I have this project I need to do, and I have no clue where to start, I was wondering if you guys could help me out.
    I need to know how to write an XML file using a Java Program, but without using a Third party library.... just using java native APIs.
    I will probably take the values to construct the file from a form.
    I will certainly appreciate if you could post some sample code for me.
    Thank you very much in advance..

    Hello there!,
    I have some doubts about the Tutorial I am currently reading. correct me If I'm wrong, but the section "Write a simple XML file" teaches you how to do so using a text editor. I need to create my XML file from a running Java Program written by myself, that takes the values to build it from some variables.
    If I'm totally wrong about what I'm saying, could you please point me to where I can find the information of how to do what I'm asking for, inside the tutorial.
    Thank you very much,...
    sincerely.

  • Actionscript 2 -- write a local file

    So I am working on extending a flash kiosk software and I need to be able to write a text file locally. The swf will not be running on a server, but on that local machine so I was wondering how I would do that.  I tried using fileReference.upload but it isnt creating the file.

    it looks like fscommand is the way to go.... if i can get it working....

  • Need to write/delete a file (token) to/from user's home directory

    I want to build a class that runs on Windows/Unix clients. It needs to get to users' home directories (both environments) and write the token on login, delete it on logout.
    What method (or code snipet) would get a user's home directory?
    What method (or code snipet) would write/delete a file from it?
    Thanks much

    Even if you are not writing an Applet, this is applicable. But I thot if you were, you might need this.
    See 'SignedAppletDemo.java'
    http://developer.java.sun.com/developer/technicalArticles/Security/Signed/

  • How to get OutputStream/Writer for a file in a JSP code?

    In a JSP code as shown below, how could we get an OutputStream to write a file that resides on the server file system?
    I'm stuck after five hours struggle!
    <%
    /* simple experimental JSP program */
    ...  // get request data
    Properties pt = new Properties();
    Class clas = getClass();
    InputStream is = clas.getResourceAsStream("/users.properties");
    pt.load(is);
    String userNameDB = pt.getProperty("user");
    String passwordDB = pt.getProperty("password");
    long lastLogonDB = Long.parseLong(pt.getProperty("lastLogon"));
        // so far so good ...
    if (userName.equals(userNameDB) && password.equals(passwordDB)){
      if (lastLogonForm > lastLogonDB) {
        session.setAttribute("User", userName); //Saves user name string in the session object
        pt.setProperty("lastLogon", lastLogon);
        pt.setProperty("user", userNameDB);
        pt.setProperty("password", passwordDB);
        ...  // how to write back the new data to the users.properties file?
    %>

    I have found a solution:
    String path = application.getRealPath("/users.properties");
    InputStream is = new FileInputStream(path);
    is.close();
    OutputStream os = new FileOutputStream(path);
    os.close();getResourceAsStream() is oddly incompatible with the code using the getRealPath(). So don't use it.

  • Write xmp sidecar files without need to export masters - script

    I've written a script to write xmp sidecar files for referenced and online images (the 2 conditions in the script) of the selected images. I looked for a while at system events and other stuff to be able to write the xmp file, but i'm not a programmer, so in the end i chose the long and dirty way to do it.
    This script will export all iptc expanded fields as aperture does (creating basically the same file). It can be easily adjusted to include other tags, even custom ones. I don't know how to get at the adjustments for images, otherwise those could be included as well.
    If anyone has the energy to clean this up and make it faster, feel free to do so. Next, I'm going to try to write a script to do the opposite, import xmp sidecars for imported online and referenced files.
    Here it goes (thanks to Brett Gross for the database part to find the master filename):
    --script to create sidecar xmp files for referenced files without having to export masters. parts of the script (finding the file name) are by brett gross
    property p_sql : "/usr/bin/sqlite3 "
    global g_libPath
    on run
    my getLibPath()
    --counter for processed images, reset, just in case
    set mastercount to 0
    tell application "Aperture"
    if not (exists selection) then
    display dialog "You have to select at least one image" buttons {"OK"} default button 1
    return
    else
    display dialog "You have selected " & (count of selection) & " images." & return & "Continue?" default button 1
    end if
    set theSel to selection
    --run through the selected images
    repeat with currentpic from 1 to count of theSel
    tell item currentpic of theSel
    -- only apply to referenced and online images
    if referenced and online then
    set mastercount to mastercount + 1
    set curID to id
    --find the master file path and name - this part by brett gross, thanks
    set libPOSIX to POSIX path of g_libPath
    set libDBPOSIX to (libPOSIX & "/Aperture.aplib/Library.apdb") as string
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZFILEUUID from ZRKVERSION where ZUUID='" & curID & "'\""
    set ZFILEUUID to do shell script theScript
    # ---------- Get the master's path
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZIMAGEPATH from ZRKFILE where ZUUID='" & ZFILEUUID & "'\""
    set ZIMAGEPATH to do shell script theScript
    # ---------- Get the master's disk name
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZFILEVOLUMEUUID from ZRKFILE where ZUUID='" & ZFILEUUID & "'\""
    set ZFILEVOLUMEUUID to do shell script theScript
    set theScript to p_sql & (quoted form of libDBPOSIX) & " \"select ZNAME from ZRKVOLUME where ZUUID='" & ZFILEVOLUMEUUID & "'\""
    set diskName to do shell script theScript
    set imgPath to (diskName & "/" & ZIMAGEPATH)
    --end brett gross part
    --strips extension, seems to work for files and paths with more than one period
    set oldlim to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "."
    try --remove last extension only
    set contador to text item -1 of imgPath
    set noExtension to Unicode text 1 thru -((count of contador) + 2) of imgPath
    on error --handle files with no extensions
    set noExtension to imgPath
    end try
    set AppleScript's text item delimiters to oldlim
    --create the file and path name with the .xmp extension for writing
    set xmpPath to "/Volumes/" & noExtension & ".xmp" as Unicode text
    --convert posix path to alias for easier write and read handling
    set xmpPath to POSIX file xmpPath as file specification
    -- header for xmp file
    set xmpheader to ("<?xpacket begin='' id=''?>
    <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9-9, framework 1.6'>
    <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>") & return
    -- footer for xmp file
    set xmpfooter to ("</rdf:RDF>
    </x:xmpmeta>
    <?xpacket end='w'?>") & return
    --xmp content, part 1
    --check for existence of iptc tags, create content or empty string depending on existance of tags
    if (exists IPTC tag "Contact") or (exists IPTC tag "Country/PrimaryLocationCode") then
    set xmpcontentpartone to ("<rdf:Description rdf:about='' xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>") & return
    try
    set CountryCode to value of IPTC tag "Country/PrimaryLocationCode"
    set xmpcontentpartone to xmpcontentpartone & tab & "<Iptc4xmpCore:CountryCode>" & CountryCode & "</Iptc4xmpCore:CountryCode>" & return
    end try
    try
    set CreatorContactInfo to value of IPTC tag "Contact"
    set xmpcontentpartone to xmpcontentpartone & tab & "<Iptc4xmpCore:CreatorContactInfo>" & CreatorContactInfo & "</Iptc4xmpCore:CreatorContactInfo>" & return
    end try
    set xmpcontentpartone to xmpcontentpartone & ("</rdf:Description>") & return
    else
    set xmpcontentpartone to ""
    end if
    --xmp content, part 2
    --check for existence of iptc tags, create content or empty string depending on existance of tags
    if (exists IPTC tag "Category") or (exists IPTC tag "City") or (exists IPTC tag "Country/PrimaryLocationName") or (exists IPTC tag "Credit") or (exists IPTC tag "DateCreated") or (exists IPTC tag "Headline") or (exists IPTC tag "Province/State") or (exists IPTC tag "Source") or (exists IPTC tag "SpecialInstructions") or (exists IPTC tag "SupplementalCategory") or (exists IPTC tag "Writer/Editor") then
    set xmpcontentparttwo to ("<rdf:Description rdf:about='' xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>") & return
    try
    set Category to value of IPTC tag "Category"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Category>" & Category & "</photoshop:Category>" & return
    end try
    try
    set City to value of IPTC tag "City"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:City>" & City & "</photoshop:City>" & return
    end try
    try
    set Country to value of IPTC tag "Country/PrimaryLocationName"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Country>" & Country & "</photoshop:Country>" & return
    end try
    try
    set Credit to value of IPTC tag "Credit"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Credit>" & Credit & "</photoshop:Credit>" & return
    end try
    try
    set DateCreated to value of IPTC tag "DateCreated"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:DateCreated>" & DateCreated & "</photoshop:DateCreated>" & return
    end try
    try
    set Headline to value of IPTC tag "Headline"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Headline>" & Headline & "</photoshop:Headline>" & return
    end try
    try
    set State to value of IPTC tag "Province/State"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:State>" & State & "</photoshop:State>" & return
    end try
    try
    set Source to value of IPTC tag "Source"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Source>" & Source & "</photoshop:Source>" & return
    end try
    try
    set Instructions to value of IPTC tag "SpecialInstructions"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:Instructions>" & Instructions & "</photoshop:Instructions>" & return
    end try
    try
    set SupplementalCategory to value of IPTC tag "SupplementalCategory"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:SupplementalCategory>" & SupplementalCategory & "</photoshop:SupplementalCategory>" & return
    end try
    try
    set CaptionWriter to value of IPTC tag "Writer/Editor"
    set xmpcontentparttwo to xmpcontentparttwo & tab & "<photoshop:CaptionWriter>" & CaptionWriter & "</photoshop:CaptionWriter>" & return
    end try
    set xmpcontentparttwo to xmpcontentparttwo & ("</rdf:Description>") & return
    else
    set xmpcontentparttwo to ""
    end if
    --xmp content, part 3
    --check for existence of iptc tags, create content or empty string depending on existance of tags
    if (exists IPTC tag "Byline") or (exists IPTC tag "Caption/Abstract") or (exists IPTC tag "CopyrightNotice") or (exists IPTC tag "Keywords") or (exists IPTC tag "ObjectName") then
    set xmpcontentpartthree to ("<rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'>") & return
    try
    set creator to value of IPTC tag "Byline"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:creator><rdf:Seq><rdf:li>" & creator & "</rdf:li></rdf:Seq></dc:creator>" & return
    end try
    try
    set description to value of IPTC tag "Caption/Abstract"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:description><rdf:Alt><rdf:li xml:lang='x-default'>" & description & "</rdf:li></rdf:Alt></dc:description>" & return
    end try
    try
    set rights to value of IPTC tag "CopyrightNotice"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:rights><rdf:Alt><rdf:li xml:lang='x-default'>" & rights & "</rdf:li></rdf:Alt></dc:rights>" & return
    end try
    --keywords, slightly different, as they need to be written as a list and not as a string
    --i don't think it's a problem if we create an empty list if there are no keywords present.
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:subject><rdf:Bag>" & return
    --make list item for every keyword
    try
    repeat with n from 1 to count of keywords
    set cursubject to name of (keyword n)
    set xmpcontentpartthree to xmpcontentpartthree & tab & tab & "<rdf:li>" & cursubject & "</rdf:li>" & return
    end repeat
    end try
    set xmpcontentpartthree to xmpcontentpartthree & tab & "</rdf:Bag></dc:subject>" & return
    try
    set title to value of IPTC tag "ObjectName"
    set xmpcontentpartthree to xmpcontentpartthree & tab & "<dc:title><rdf:Alt><rdf:li xml:lang='x-default'>" & title & "</rdf:li></rdf:Alt></dc:title>" & return
    end try
    set xmpcontentpartthree to xmpcontentpartthree & ("</rdf:Description>") & return
    else
    set xmpcontentpartthree to ""
    end if
    --part four. aperture doesn't seem to export anything there
    set xmpcontentpartfour to "<rdf:Description rdf:about='' xmlns:photomechanic='http://ns.camerabits.com/photomechanic/1.0/'>
    </rdf:Description>" & return
    --part five. rating
    set xmpcontentpartfive to "<rdf:Description rdf:about='' xmlns:xap='http://ns.adobe.com/xap/1.0/'>" & return
    try
    set Rating to main rating
    set xmpcontentpartfive to xmpcontentpartfive & tab & "<xap:Rating>" & Rating & "</xap:Rating>" & return
    end try
    set xmpcontentpartfive to xmpcontentpartfive & "</rdf:Description>" & return
    --join everything
    set xmptext to xmpheader & xmpcontentpartone & xmpcontentparttwo & xmpcontentpartthree & xmpcontentpartfour & xmpcontentpartfive & xmpfooter
    --write file
    my writexmpFile(xmptext, xmpPath)
    end if
    end tell
    end repeat
    display dialog "Processed " & mastercount & " referenced and online image(s)." buttons {"OK"} default button 1
    end tell
    end run
    -- write xmp sidecar file routine
    on writexmpFile(theContents, xmpFileName)
    --tell application "Finder"
    try
    open for access xmpFileName with write permission
    set eof of xmpFileName to 0
    write (theContents) to xmpFileName starting at eof
    close access xmpFileName
    on error
    try
    display dialog xmpFileName
    close access xmpFileName
    end try
    end try
    --end tell
    end writexmpFile
    --this part copied from Brett Gross-------------------------------------------------------------------------- --------------------------------
    on getLibPath()
    tell application "System Events" to set p_libPath to value of property list item "LibraryPath" of property list file ((path to preferences as Unicode text) & "com.apple.aperture.plist")
    if ((offset of "~" in p_libPath) is not 0) then
    -- set p_posix to POSIX file p_libPath
    set p_script to "/bin/echo $HOME"
    set p_homePath to (do shell script p_script)
    set p_offset to offset of "~" in p_libPath
    set p_path to text (p_offset + 1) thru -1 of p_libPath
    set g_libPath to p_homePath & p_path
    else
    set g_libPath to p_libPath
    end if
    end getLibPath
    --end brett gross part

    imigra wrote:
    I've written a script to write xmp sidecar files for referenced and online images (the 2 conditions in the script) of the selected images. I looked for a while at system events and other stuff to be able to write the xmp file, but i'm not a programmer, so in the end i chose the long and dirty way to do it.
    This script will export all iptc expanded fields as aperture does (creating basically the same file). It can be easily adjusted to include other tags, even custom ones.
    Excellent stuff!
    I don't know how to get at the adjustments for images, otherwise those could be included as well.
    They are stored as binary data in the Version XML files at the bottom level of the Library package. You can also have a look around in the ZRKIMAGEADJUSTMENT table, but again the actual settings for each adjustment are in binary form.
    If anyone has the energy to clean this up and make it faster, feel free to do so.
    As far as I can remember, Aperture uses the 'proper' IPTC tag names when accessing them via AppleScript, so you may be able to do a loop through all the IPTC tags for each image, rather than picking out each specific one. But that would need checking. The EXIFTools site is a good place to find out about the different ways that IPTC data can be described.
    Next, I'm going to try to write a script to do the opposite, import xmp sidecars for imported online and referenced files.
    Don't rush unless you feel like it - I've already started planning out a free (as in beer and speech) XMP importer with a GUI so that you can choose how to map the XMP CORE tags that don't exist in Aperture. You've given me an extra idea, though - if we can decide on a set of custom tags, my importer could map the XMP CORE tags to them and your exporter could export those tags.
    Thanks for the work!
    Ian
    P.S. I'll check through your script tomorrow, some of the database tables changed between 1.5.6 and 2.0, so you might need to add in a version check to be really thorough.

  • I need to have endnotes at the end with sections and numbering beginning again for each section. I also need to be able to write Chapter

    I need to have endnotes at the end with sections and numbering beginning again for each section. I also need to be able to write Chapter #s above each section of endnotes. How do I do this, please?

    I have precisely the same problem and am wondering if anyone has found a workaround for what seems to be a bug or an unattended issue in Pages. Hopefully the next update (whenever it arrives, I hope it arrives soon) will take care of this.

  • From PLSQL - Need to write a text file

    Hello
    I need to write a text file from data retrieved from many tables in PLSQL to the UNIX box.
    Thanks
    Paul
    null

    You can use package UTL_FILE to write out to a file. Your DBA has to make initialization changes to support this. They might already have it setup. Run this query:
    SELECT value
    FROM v$parameter
    WHERE name = 'utl_file_dir';
    To see whether it has been configured properly. The value is the directory where you can create and write files.
    null

  • Write Characters to file.vi only outputs 3 columns, I need 4.

    I can format columns with 'tab', but I get a linebreak after column 3 so that data_4 appears on a new line.
    I cant find any line breaks.
    Attachments:
    iridium_two_channels_working_copy.llb ‏80 KB

    The line breaks are coming from the format to spreadhseet string functions...use a format number to fractional string function instead (on the string palette).
    Other observations;
    The sequence structure is not necessary, things will execute in the correct order if you let the data flow control the execution instead...and then the code becomes more readable.
    To use the write characters to file repeatedly in a for loop makes things very slow because then the file is opened and closed for each iteration...instead open the file prior to the loop, just do a write in the loop..and close the file when the entire loop has finished, if there is a lot of iteration to do this will speed up the executing tremendously...
    Mads
    MTO

  • When there is web service request, we need to write to text file

    Hello, Im currently using a web service request (particularly the read request variable). What my application does is that when a user enters the url
    http://127.0.0.1:8001/WebService/Process?1=1&2=0&3​=1&4=0&5=0
    LED 1 and 3 turns on, while the other LEDs are turned off. I would like also to keep text file logs on what is the current time now, and the status of the LEDs. I want only to write to the file everytime the user enters the query in the URL (I dont want to write the logs every second or so, just only when the user presses the go button in the browser) 
    I can now write to a text file the current datetime stamp, and already setup the web services. But I cant figure out how can I execute this write process everytime the user fires up a web request.
    Basically, how can I write to a text file the status of the LEDs each time there is a URL request? 
    Attached is the project. Thanks
    Attachments:
    DOE_LabView_v2.zip ‏15 KB

    One reason you might not be getting any errors is that you aren't looking for errors. Connect up the error clusters and then display what you get.
    Where are you getting the path that you are writing to?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Using Swing applet to write data to file on SERVER

    Hello,
    I'm in the process of writing an applet using Swing (SDK v1.4.2). Here's the deal. The JApplet calls a JPanel, which will be used by customers on my site to enter data. I'm adding a <Save> button to the "form" which is supposed to write data to a file on the server (in order to preserve the customer's preferences).
    Please note that I am NOT attempting to write data to the customer's hard disk. That requires digital certificates, etc. which I am trying to avoid for now.
    Instead, I am using the URL class to access the file:
    URL page = new URL("http://www.whatever.com/mycustomers/preferences.txt")
    I then use the URLConnection class to establish the connection:
    URLConnection conn = this.page.openConnection();
    conn.setDoInput(true);
    conn.setDoOutput(true);
    conn.connect();
    etc...
    I've created a text file (preferences.txt) on my web site. Using the classes InputStreamReader, BufferedStreamReader, and StringBuffer, I can successfully read the file into a JOptionPane in my applet.
    The problem comes when I try to write data TO this file. I know the file exists because the applet can read it. I've set the permissions on the file to 666. I've got all of the appropriate syntax within a try statment that catches an IOException. I also have JOptionPanes all over the place to let me know where the program is. I've tried different combinations of output streams like BufferedWriter, BufferedOutputStream, StringWriter, but the file does not get updated. When the applet runs, it does not throw any exceptions, not even when I change the URL from "HTTP://www.whatever.com/prefs.txt" to "HTTP:/www.whatever.com/prefs.txt" (only one slash on HTTP, shouldn't I get a MalformedURLException?)
    I apologize for all the background, but I thought you might need it. The bottom line is:
    1) Can an applet write to a file on a remote server (not local hard disk)?
    2) If so, what (if any) caveats are there?
    3) Is there a way to check for file existence or be able to create a new file?
    4) I'm using the HTTP protocol - is there some restriction that prevents an applet from writing to a file using that protocol? If so, is there a workaround?
    5) Assuming that creating/writing a file using the method I've described is possible, what would be the appropriate output streams to use? (Currently, I'm using OutputStreamWriter with BufferedWriter).
    I've been struggling with this for a while. Any help/suggestions would be appreciated.
    Thanks
    P.S. I also posted this message on the Applet development forum, but I've received no response as of yet.

    Http servers support PUT as a mechanism to upload data to a specified URL. Get on the other hand which is what most people are familiar with is how you retrieve that data. The basic URLConnection is an abstraction of the Http connection which can be used for GET and POST operations by default based on doInput(true|false).. If you which to use any of the http methods other than GET|POST you will have to cast the URLConnection to HttpURLConnection so you can gain access to the specific Http functionaility that could not be abstracted.
    Since you are using a hosting service the chances are that you won't be able to use HTTP PUT on their server. Most servers do not support HTTP PUT without configuring them todo so. Now Apache allows localized config through the .htacess file. It might be possible (keep in mind I am not an apache expert) to configure a particular directory to allow HTTP PUT using this .htacess file it may not be possible. You will have to consult the Apache web server documentation for that answer.
    But regardless you can use the HttpURLConnection and the PUT method to send data from your applet to the server. In fact that is the preferred way to do this. If you can not configure your web server to support that method then you will have to develop a Servlet to do it. A servlet has several methods such as doGet(), doPost(), and doPut(). You would override the doPut() method get the URI path create a file and a FileOutputStream to that file, get from the request the inputstream, possibly skip the http headers, and then write byte for byte the incoming data to your OutputStream until you reach the end at which point you would close the OutputStream and send an Http Response of some sort. Typically in HTTP it would be 200 OK plus some web content. You content can be empty so long as your applet recognizes that is what it should expect...
    And away you go...

  • Write in a file using FileConnection

    Hello, I have to write in a file using the FileConnection API (JME).
    So far, I could write it, but I could not find out how to append in the file.
    Here is the code:
    FileConnection fc = (FileConnection)
    Connector.open("file:///test.txt");
    OutputStream os =  fc.Open(OutputStream);
    OutputStreamWriter osw = new OutputStreamWriter(os);
    osw.write("test");
    How can I add new data at the end of the file?

    Well, I really can't find a method I could use, so I read the file and put it in a buffer, then I write it all.
    I will let the code for anyone who needs:
    +try {+
    FileConnection fc = (FileConnection) Connector.open("file:///j9/test.txt");
    if (!fc.exists())
    fc.create();
    InputStream is = fc.openInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    +char[] c = new char[(int) fc.fileSize()];+
    isr.read(c);
    OutputStream os = fc.openOutputStream();
    String str = textField.getString() ',' + textField1.getString() + '\n';+
    os.write(new String(c).getBytes());
    os.write(str.getBytes());
    os.close();
    is.close();
    isr.close();
    fc.close();
    stringItem1.setText("It works");
    +}+
    +catch (Exception ex) {+
    stringItem1.setText("It doesn't work");
    +}+

  • Write to spreadsheet file.vi is storing data in one row only.

    The 8 points of data is going into one column in the spreadsheet. In the "Write to spreadsheet file string.vi" how do I write the 8 points to one row for each cycle?
    I got this VI from NI's web a couple of years ago and forgot how to modify this part. I usume it is within the write file.vi.
    Thank you in advance
    Skip

    I just reread your original post and the way the "Write to Spreadsheet File.vi" that ships with LV works by default is to put 1D arrays into rows. I read your post backwards and told you how to put the data in a column. Sorry.
    In any case, perhaps you need to make sure the Transpose input ISN'T true, and that the delimiter IS a tab.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • WIN7 x64 Home Basic, 0x80070013 when trying to write or delete files. Disk is write protected.

    Hi,
    My SD card reader is not able to write or delete and format sd cards.
    WIN7 x64 Home Basic, 0x80070013 when I trying to write or delete files. When I trying to format I can see a message that disk is write protected. 
    The card is not locked, it's work in Lenovo Idea Pad s10 without any problem, It's also work in my Pentax camera.
    I'm almost sure that the problem is software, but can't find solution.
    Could Any one help me please?
    Laptop is new, 8 days in use. 

    I have network shutdown 2.0.1 installed and the pcns process normally would be abend in 1 or 2 minute's time. What could be the problem ? Consider to upgrade the network shutdown to 2.2.1 version. Could the problem be resolved in new version ? Any precaution needs to be taken when installing the new version ?
    Terence.

  • How to combine both DAQ AI signal, write and read file in single VI

    Hi
     I am the new user of LabVIEW version 7.1 for testing automation application. I have to measure 33 signals ( mostly analog like temp, pressure, etc...) from NI USB 6210 DAQ system and write in master file for future verfication.From real data or from master file back up have to write  one more file if only the signal reaches steady state , which will used for analysis and same signals to be read from this file parallely & make a waveform and/or table display format.
    Pl. help me to shortout this problem 
    note: I have plan to ugrade labVIEW version 2011 shortly, so let me know doing parrel acquistion write and read file for data analysis in same VI in version 7.1...... 

    Parallel operations in LabVIEW are very simple.  Just code it in parallel and it will work.
    Try taking a look at some of the examples in the NI Example Finder (Help > Find Examples).  There you will find example for writing to and reading from files, as well as data acquistion in parallel with other operations.
    You might need a producer/consumer architecture is you are acquiring data very quickly.
    Chris
    Certified LabVIEW Architect
    Certified TestStand Architect

Maybe you are looking for

  • Function module for getting stock details for a given period or date range

    Hi experts,      Any function module available for getting stock details batch, plant, storage location, and period wise. <<removed_by_moderator>> Thanks in advance M Prasanna Edited by: Vijay Babu Dudla on Apr 28, 2009 7:23 AM

  • How to use rollup function?

    here is my sql query select ename,sal*nvl(comm,0)  amount from emp ENAME          AMOUNT SMITH               0 ALLEN          480000 WARD           625000 JONES               0 MARTIN        1750000 BLAKE               0 CLARK               0 SCOTT  

  • PDF security

    Hi everyone, I create artwork for a print shop and provide the owner with a pdf file which she then emails to her customers to get their approval for printing. She tells me that she's worried that if she sends high-res pdf files to her clients that t

  • JMS Control - receive-correlation-property

    Hi, I am using JMS Control in WLI 8.1. This is not a WLI JMS Control. Some application puts a message to Weblogic Queue. My JMS Control is subscribed to the queue. It gives the following error - when it receives the message... <Jun 15, 2004 4:02:56 P

  • Adobe TV videos won't load or play on iMac

    When I try to launch an Adobe TV video, where it should be, the page is just blank white. I can play videos with no problems on other sites.  I can play .flv, .mp4, .mov movies on other sites and off the hard drive. It's just Adobe TV that isn't work