Writing data to a file in Server

Hi all,
In my application i would be writing data to a file which is located in the Server.
when i tried writing data to a file in my local machine using a Java Application it worked fine .
Now through the webdynpro application and providing the files path (in server ) ,i am getting file not found exception .
I am using basic File and i/o operations .
File abc = new File ("
servernamer
folder1
subfolder1
filename.dat");
when i try accessing this path from the command prompt its opening fine.
Could you please through some light on this .
thanks,
swetha .

>
KalluriVijay wrote:
> Hi Swetha,
> Do one think.
> InputStream text = null;
>                int temp = 0;
>                //File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
>                //wdComponentAPI.getMessageManager().reportSuccess("filePath Vijay:::"+file);     
> //wdComponentAPI.getMessageManager().reportSuccess("filePath Vijay:::");
>                     try
>                     {
>                     String fileName = wdContext.currentContextElement().getResource().getResourceName().toString();               
>                     if(fileName.equalsIgnoreCase("ASNCRT.dat"))
>                     {     
>                     File file = new File(fileName);                         
>                     FileOutputStream op = new FileOutputStream(file);          
>                     if (wdContext.currentContextElement().getResource()!= null)
>                     {
>                     text = wdContext.currentContextElement().getResource().read(false);
>                     while((temp=text.read())!= -1)
>                     {
>                     op.write(temp);
>                     }
>                     }
>                     op.flush();
>                     op.close();
>                     path = file.getAbsolutePath();
>                     //wdComponentAPI.getMessageManager().reportSuccess(path);
>                     }
>                     else
>                     {
>                     wdComponentAPI.getMessageManager().raiseException("Please Check the Filename:Filename should be ASNCRT.dat ",true);     
>                     }
>                     }
>                     catch(Exception ex)               
>                     {
>                     ex.printStackTrace();
>                     }
> By using this code u can put u r file in to Server Path, then u will get the that .dat file from server path and run the command prompt its opening fine
> How to get the file from the Server Path:
> Workbook wb = Workbook.getWorkbook(new File(path));     // For get the file from the Server path
>
>   Hope this is help full for u
> Regards
> Vijay Kalluri
This won't work. First, like i said, File class is not for accessing remote files, it is only for local files.
Second, Workbook class is a class from Java Excel API. He is not working with xls. Anyway that wouldn't work either.

Similar Messages

  • Problem while writing data on xls file using jxl API

    Hi,
    I am getting problem while writing data on excel file using jxl api.
    When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
    here is code:
              FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
              WritableWorkbook this.workbook = Workbook.createWorkbook(os);
    after writing data following handler are closed:
    this.os.flush();
                        this.workbook.write();
                        this.workbook.close();
                        this.os.close();
                        this.os = null;
    can any body help me.
    Thanks in advance

    Err, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
    And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
    But it happens often enough that it also makes me think I'm just wasting my time. Probably I am.

  • Writing Data to Multiple Files

    Hi,
    I got a problem while writing the data to multiple files.
    Actually my requirement is,
    I want to read the data from multiple files and retrieve the required data from those and save that data into separate files.
    Meaning if i read the data from "D:\kiran\kk\123\kiran.txt" the retrieved data should be saved in "D:\kiran\kk\kiran.txt" the file name should be created with the input file name.
    here is my code,
    //here i am taking the files into loop
    for(int i=0;i<files.length;i++){
    try{                   
    //reading the files
    BufferedReader br=new BufferedReader(new FileReader(files));
    //creating a new file for writing the retrieved data
    pw=new PrintWriter("D:\\Kiran\\kk"+File.separator.concat(str[i]));
    String line=br.readLine();
    while(line!=null){
    line=br.readLine();
    //here i am matching the required data
    Matcher m = Pattern.compile("name(\\s*\\W*\\w*\\W*.\\w*.)|invoice (\\W*(\\d+))|amount(\\W*(\\d+),\\d*)|site(\\s*Rs\\.[\\d]*,[\\d]*/-)", Pattern.CASE_INSENSITIVE).matcher(line);
    while(m.find()){                           
    System.out.println(m.group());
    //here printing the retrieved data to a file
    pw.println(m.group());
    br.close();
    but i am ending up with some issues.
    Data is reading properly from all the files, but when i write that data into individual files the data which is retrieved from last file is only printing into the file which is created last.
    Please help me regarding this,
    Thanks,
    Kiran

    D:\kiran\kk\123\
    In this folder some files are there say,
    kk.txt,kiran.txt,praveen.txt and so on, i can read the entire data from those files and also retrieving the required data like name,data etc. from all the files. Now the retrieved data should be stored in individual files means, if the data is retrieved from kk.txt then that particular data should be stored in the file with the same file name but in different location likewise it should happen for all the files those are in that folder.
    Thanks,
    Kiran

  • Writing Data to a file using TEXT_IO in Forms

    I have a situtation where i have 5 columns and having arabic as well as english data. when i want to write this data to a txt file using TEXT_IO in a specific format, it writes to a file but as soon as it finds an arabic field, it changes the posistion. how can i write to a txt file in the posistion i want???

    vaishnavinatarajan wrote:
    How to write data to a file without leaving any blank lines in the file? How to check if the cursor is placed in the corner of a notepad file using LAB VIEW?
    If you write data to a file, simply don't include any blank lines. We cannot give more specific advice unless you are telling us how you are writing. Are you writing to a new file or appending to an existing file. If the blank lines already exist, you need to read the entire file, remove the undesired lines from the string, and write the data back.
    Notepad files don't have any "corners". Please describe what you are trying to do.
    What is "LAB VIEW"?
    LabVIEW Champion . Do more with less code and in less time .

  • Problem in writing data to flat file

    Hi,
    I have created an interface with table as source and file as target. My interface is running from long time but its not writing data into file. Any clue?
    -Chikk

    Hi,
    Please, take a look if the target file is locked.
    Try to delete it and put the "Truncate" option from IKM to yes.
    Cezar

  • By a sub VI, Writing data countinously to file by a ''Write' button in Main VI??

    Good morning...day  to all !
    I've made a program, where I'm reading data generated by a device connected to a com port. These data are red from the port to an indicator buffer and then, into a file when a button, " write file" are pressed. I've placed the 'WriteDataToFile.VI' in a Sub VI placed in Main VI.
    When my Main Program starts and I switch a start button, a file dialog box opens, so I can choose an existing file or a new file to write data to!
    I want to Make a Button named  " Write file" so when pressed , the Dialog box opens and I can choose a file to write to.
    In that way I can avoid the Self pop up dialog box.
    I've spended the hole weekend  trying doing that, but no succes. The biggist problem by that is:
     To write a continously to a file I  also need to continously read the data from the port, And because of that, I got to write the data to a file as quickly as possible when Red from the port. So I gotta put the WriteDataToFile.VI 'sub', in the ReadData:vi 'Sub'. By that I always get the Dialog box poped up, by each while loop iteration. Just because the Software to the open Dialog Box (Write file), is placed in the ReadDataVI, Sub.
    Please Help me with that Guys , girls, any one, also peoble from Mars To!
    Attachements !!
    Regards
    H.F.Zamzam    
    HFZ
    Attachments:
    ReadDataWriteToFile.vi ‏62 KB

    Hi Zamzam,
    I think the point you should work on is the architecture of your whole application, LabVIEW has very well designed templates.
    If you go to new >> new... >> vi from template >> frameworks >> design pattern >> user interface event handler
    It is a very robust architecture with which you can draw cases for (almost) any kind of event such as a click on a button.
    in your application, you could choose the file to write on the first run, then put the file refnum in a shift register and add an event case handled by the "write to file" button that writes the acquired datas.
    You could even go further and set that "wite fo file" case on other event, for instance new data from the port com.
    wooopps... I tried to be as clear as I could but english is not my natural language , so please tell me you need some more help
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • Writing data in text file..

    1. check the file name in D:\\temp\\test.txt
    2. if it exists, then open file. if there is data, then read data. after the last record, it writes new data.
    3. if it does not exist, create text.txt file and write data into text.txt file.
    so far, I have a code..
    import java.io.*;
    import java.util.*;
    public class Main {
    public static void main(String[] args) {
    String filename="test";
    String format = "%1$-9s%2$-3s%3$-30s%4$-30s%5$-30s\n";
    String arraydata[] = { "John", "F.", "Kennedy", " ", "t", "John2", "F2.", "Kennedy2", " ", "t2"};
    String cnt_id ="2";
    int cnt_orderid = Integer.valueOf(cnt_id);
    try
    PrintStream ps = new PrintStream(new FileOutputStream("D:\\temp\\"+filename+".txt"));
    for (int i=1; i<cnt_orderid; i++)
    ps.println(String.format(format, (Object[])arraydata)); // write in test.txt file
    ps.close();
    catch (Exception e)
    System.out.println(e);
    my question is..
    1. how to check the file exists or not
    2. how to write the data in the new line after the last data in the file.

    1. Use a File object.
    File file = new File("someFile.txt");
    if (file.exists()) { ... }2. Consider using FileWriter; the constructor allows you to append to the end of the file:
    FileWriter fileWriter = new FileWriter(file, true);Michael

  • Writing data in text file in KM

    Hi Experts,
    I am trying to write content in KM. my query is
    1) I tried with FileManagement, But it doesnn't work in KM. Why?? working well with file saved on server.
    2) I tried following code. But there in no exception,error and no result...
    try{
         String upstr="some data";
         IUser user =WPUMFactory.getUserFactory().getEP5User(req.getUser());
         ByteArrayInputStream data = new ByteArrayInputStream(upstr.getBytes());
         Content content = new Content(data,"text,plain",data.available()); //test
         ResourceContext ctxt = new ResourceContext(user);
         RID rid =RID.getRID("/documents/test.txt");
            ResourceFactory.getInstance().getResource(rid, ctxt).updateContent(content);
    }catch(Exception e){}
    Can you help please??
    Thanks in advance.
    Regards,
    Mehul

    Hi Mehul,
    -->I tried with FileManagement, But it doesnn't work in KM. Why?? working well with file saved on server.
    It is unclear what type of Repository you are using/having (FSDB/Webdav) and what you are trying to do!
    http://help.sap.com/saphelp_nw2004s/helpdata/en/62/468698a8e611d5993600508b6b8b11/frameset.htm
    --> I tried following code. But there in no exception,error and no result
    Use the below code to get things working
    public static IResource getOrCreateResource(String name, IResourceContext resourceContext)
            throws ResourceException {
            if (name != null) {
                name = name.trim();
            // Check that no part of the name has leading or trailing spaces / underscores
            RID collectionRID = RID.getRID(name);
              IResource collection = null;
              if (!ResourceFactory.getInstance().checkExistence(collectionRID, resourceContext)) {
    //In this method, passing true will create new Resource if not exists
                   collection = (IResource) ResourceFactory.getInstance().getResource(collectionRID, resourceContext, true);
              }else{
                   collection = (IResource) ResourceFactory.getInstance().getResource(collectionRID, resourceContext, false);
      return collection;
    IResource resource = getOrCreateResource(String name, IResourceContext resourceContext)
    String dataString = new String(content);
    ByteArrayInputStream dataStream = new ByteArrayInputStream(dataString.getBytes());
    IContent newContent = new Content( dataStream, text/plain, dataStream.available() );
    resource.updateContent(newContent);
    Also check this:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5d0ab890-0201-0010-849d-98d70bd1d5f0
    Greetings,
    Praveen Gudapati
    p.s. Points are always welcome for helpful answers

  • Writing data to log file

    Is it possible to write data to a log (text) file from within Crystal Reports, possibly in a UFL?  Is there a way that's already built in to CR?
    Thanks.
    Ron

    Ido - thanks for the link.  This will help.
    Don,
    Not exporting a report to a text file.  More like logging report events. One of my report developers was thinking of maybe tracking the start/stop times of each publication per person as well as the full run time.
    I hope I explained that correctly. 
    Thanks.
    Ron

  • Somebody experience with writing data in Access file?

    I want to write my data in a Access file.
    Is it true, that I have to create a macro in the Access-file?
    I have no experience with macros. Can somebody tell me how I can do that?
    Has somebody an example?
    Thanks for help.

    No, you don't have to write a macro. I guess you're refering to the shipping example that uses DDE. Instead of DDE, you can use ActiveX. There have been several examples posted to the forum that use this to read and write from an Access database. There is also the Database Connectivity Toolkit from NI that uses ODBC/ADO/SQL to talk to any database. For a free utility, check out LabSQL from Jeffrey Travis at http://jeffreytravis.com/lost/download/.

  • Writing data in a File

    When I got my output into a file each line has "OD" at the end . What is this ? and How can I fix it?
    Thank you!!!

    When you are writing in a file, which stream are you using? Character stream or byte stream? And after that, are you using the formatter class to format the output. Please give details.

  • Streaming data and writing data to measurement file problem

     Hi everyone,
    I found something wrong about my code but i don't know exactly what it is first i have a program for acquiring 15 analog signals(NI PXI6259) after acquiring the data i use network stream to stream data from my NI PXI8186 to the host pc these steps are in target VI, after streaming data to host PC
    , i tried to write down the data to the spreadsheet using Express write to measurement VI.
    Problems : 1. After i run the host Vi and target Vi the number available to read is always 0 after sometimes the data displaying on the chart incdicator on host Vi is stopped and start counting the numberavailable to read also the time indicated on X axis of the chart doesn't grow.
                         2. Write to measurement file generate the file that record the data counting the data from 0 to 99 and start over and over again
     Please help i really have no idea what is the cause for each problems.
    Attachments:
    target - single rate.vi ‏83 KB
    Host UI.vi ‏36 KB

    Dear Crossrulz
            Thank you for your prompt reply i have removed the input to "Samples Per Channel" on the DAQmx Timing VI already but still didn't arrange the 
    channels input i will do it but i want to keep it this way first. Now the data acquiring looks okay but i have found new problem.
            After running the program for acquiring the data for about 5 to 6 minutes the program will stop acquiring the data or
    sometimes the target (NI pxi8186) will reboot itself and displaying message "Reboot due to system error" "System state: Safe Mode (System error)
    and on the Host PC there will be a window pop-up displaying
    "Waiting for the target (NI-PXI8186-2F0a597C) to respond"  "Stop Waiting and Disconnect"
     i didn't run the host Vi just run the target Vi only. If this problem caused from the program or the hardware ? Please help.
    Attachments:
    Host UI.vi ‏141 KB
    target - single rate.vi ‏83 KB

  • Scheduling BW Query to store data as CSV file on server

    Good Morning,
    I have a user requirement to schedule a BW query using the Reporting Agent but to store the results in CSV format on a shared network drive rather than printing out the contents. Is this possible? I'm using BW 3.0
    Many thanks in advance.
    Mike

    Hi Mike,
    Refer thez link below regarding Openhub
    http://help.sap.com/saphelp_nw04/helpdata/en/ce/c2463c6796e61ce10000000a114084/frameset.htm
    · BW Open Hub (ppt)
    https://websmp204.sap-ag.de/~sapidb/011000358700002201112003
    · BW Open Hub - Transcript (doc)
    https://websmp204.sap-ag.de/~sapidb/011000358700002320152003
    How to guide on RSCRM_BAPI
    http://help.sap.com/saphelp_nw04/helpdata/en/49/7e960481916448b20134d471d36a6b/frameset.htm
    https://forums.sdn.sap.com/click.jspa?searchID=3318270&messageID=3626098
    hope it helps

  • Writing data  in Excel file

    hi,
    i want to write the output of my jsp in an excell sheet. anybody teell me the way and the source code for this. Thanks in advance
    Sathaa

    Check out
    org.apache.poi
    it has a lot of tutorials on how to use excell with java

  • How can FMS create a text file and write data into it in the Server application folders?

    Recently, I writed a programe about creating a text file and writing data into it in the server application folder. My code is as following:
               var fileObj = new File("/MyApp/test.txt");
               if( fileObj !=  null)
                      if(fileObj.open( "text", "append"))
                            fileObj.write( "                                                      ———— Chat Info Backup ————\r\n" );
                            fileObj.close( );
                            trace("Chat info backup document :" +  fileObj.name + " has been created successfully!");    
    But when I run it, FMS throw the error as following: File operation open failed  ;  TypeError: fileObj has no properties.
    Can you help me ? Thanks in advance.
    Supplement: The text file named test.txt doesn't exist before create the fileObj, an instance of File Class.

    Is MyApp the name of the application directory, or is it a child of the application directory? If myApp is the app name, just use test.txt as the path flag in the file constructor.

Maybe you are looking for

  • Page Up and Page down functionality in table control

    Hi,     I want to add two pushbuttons in the module pool screen which has a table control that fetches data from the transparent table. One pushbutton is for the page up and other is for page down. If my table control <say tab_ctrl1> has 75 records i

  • Learn the number of pulses created in a finite pulse train

    Hello I am using the PCI-6602 Board to produce a finite number of pulses with counter0. I want to know how many pulses that are already created by the counter, while my program is running and show this number on an indicator on the front panel of my

  • Hide/Show Radio Buttons

    Hi friends, I have a radio button page item which is showing two values like <li>4 Stars <li>5 Stars I need to show these two radio buttons according to the employee number that is firing on the field Employee Number. Suppose, for an example i need t

  • If I delete an attachment in a group chat on iMessage on iOS 8, does it delete it from everyone?

    and if not, does anyone know how to do it? Or am I just going to have to get everyone to delete the group chat and start a new one?

  • Sap Archiving u0096 STO error on version ECC 6.0

    Hi experts. I take a long of time with this error and I hope that you can help me. Explain the program. We have a archiving project of no standard objects. This objects run on Sap version 4.6C, but now, on version ECC 6.0, the Store program give a ex