Empty file when writing?

I'm trying to write to a file, using this:
double rnd = 100000 * Math.random();
int trackingID = (int)rnd;
out.println(trackingID);
try
     File datafile = null;
     datafile = new File("notifier.log");
     PrintWriter dataout = new PrintWriter(new FileWriter(datafile));
     dataout.println(trackingID + "|");
     dataout.close();
     catch(IOException ioExc)
     out.println("error writing file");
For some reason, it returns no error, but my file remains empty. I tried adding something to the file, thinking if it's empty, it might not write to it, and no help.
Anyone have any ideas?
The file is in the same directory as the jsp.
Thanks!!

What you want to do - solution
Use request.getPathTranslated() to get the path of your JSP. Parse out the name of the JSP to get the folder in which the JSP is put.
What I would have done - Better Solution
IMO placing files in the same folder is bad design and my logic will bomb in most J2EE server if you deploy your application as a war. Why dont u define the folder name in your web.xml as a context parameter instead?

Similar Messages

  • Empty files when I publish

    When I publish photos from one of my publish services, sometimes they export as 0 kb files and sometimes not. It's pretty random because when I delete the empty files and republish them, some files turn out ok, but other ones are still empty. Did anyone have this problem?

    It's when I export to Dropbox also... so that's where the problem lies it seems.

  • Empty File Handling in xLink adapter

    Helloo Experts
    I am doing a scenario, which creates an empty file(when some mapping condition doesnt satisfy).
    I dont want to write this empty file in the target directory.
    This can be handled if a file adapter is used, but I am using a SOAP AXIS adapter, so I dont know how to handle this here.
    I alaso tried using the StrictXml2PlainBean to avoid the creation, it creates 0 documents and a 0kb empty file.
    Can anyone please let me know how this can be solved????
    Also if some one has done this empty file handling in J2SE file adapter...can you tell how it was done.
    Thanks a lot!!!!!!
    Regards
    Shobha

    Hi Gabriel,
                       You can write a simple script to copy a file from source folder to target in case the fiel size is ZERO bytes. The script will not copy the file if the filesize is more than zero bytes, This will be processed normally by PI server. You can call the script from sender communication channel parameter : "RUN OS command before message processing". Could you please specify the Operating System (OS) you are using in your PI server.
    Regards
    Anupam

  • Edits in iPhoto create empty files

    iPhoto '08 imports photos correctly, but creates empty files (0kb) once I edit. The original is retained correctly, and I can always "revert to original" to get the files back, but about a quarter of my edited photos show up as empty files when I try to view them.  How can I fix it?  Why does it happen to some, but not others?

    Have these been shot with a Nikon? I've seen occasional reports on here of this happening with Nikons.
    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • Creating an empty file using variable in script task

    I created an empty file by writing a code in script task. how can i use a variable to do the same job.
    System.IO.File.Create(@"C:\OneEmptyTextFile.txt");

    Hi SyedF,
    Just as you said, we should refer to the code below to create an empty file in the specified path using System.IO.File.Create:
    System.IO.File.Create(Path)
    If we want to use a variable named FilePath to control the path of the created file, please refer to the following code:
    Dim Path As String
    Path = Dts.Variables("FilePath").Value
    System.IO.File.Create(Path)
    Reference:
    https://msdn.microsoft.com/en-IN/library/ms135941.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • FTPS: Writing empty files

    Hi Gurus,
    I have PROXY -> XI -> File scenario and we have to use FTPS to secure the connection.
    I have done the following steps -
    1. Imported the public key certificate from 3rd party FTP server into the Trusted CA section of the Keystore in visual Admin. The CN name in the certificate is same as the server name maintained in communication channel.
    2. In File receiver Comm channel -
          a. I have selected the connection security as FTPS for control and data connection.
          b. command order is default command order.
          c.. Use X.509 certificate is unticked and no certificate is selected.
          d. A valid user name and password entered in comm channel. (the password is correctly entered)
          e. Target directory maintained as /xxx/xxx (which is the default directory of the user)
    3. The third party server can do FTPS as I am successfully able to connect and transfer files to the directory on that server using File-Zilla tool. When I try and connect using FTPS using File-Zilla, it prompts me for the certificate and once I accept the certificate, I can see the files in the folder. I used the same user id and password in FileZilla that I have used in comm. Channel.
    When I run the scenario (we have PI7.0), its writing empty files in the folder on the target server. When checked in RWB its throwing error - Error occurred while connecting to the FTP server "xxxx.xxxx.com:21": iaik.security.ssl.SSLCertificateException: Peer certificate rejected by ChainVerifier.
    If I change the target directory from the /xxx/xxx to '/' (without quotes) then no file is written and I get error - An error occurred while connecting to the FTP server 'xxx.xxx.com:21'. The FTP server returned the following error message: 'com.sap.aii.adapter.file.ftp.FTPEx: 553 Could not create file.'. For details, contact your FTP server vendor.
    The permissions for the folder are 777 and the file name is as simple as abc.xml.
    My contact on the target server is not able to help either as I am able to connect to his server using FTPS.
    Not sure whats going wrong. Any help will be appreciated.
    Thanks,
    Rahul.

    Hi Rahul,
    Try selecting the keystore and X.509 certificate that you loaded in VA, in the communication channel.
    I think you need to specify this certificate in communication channel for verification.
    Also please check Q24 of Note 821267 - FAQ: XI 3.0 / PI 7.0/ PI 7.1 File Adapter (I think you loaded the certificate to trustedCA as described in this note)
    if didnt work check your command order AUTH TSL,USER,PASS,PBSZ,PROT
    have look into this thread as well Re: FTP/SSL Connection Problem for FTP Receiver Adapter
    regards,
    francis

  • Writing files with Eclipse over gvfs ends in empty files

    Hello,
    I'm using gvfs to mount folders from our development server. I'm accessing these folders directly with Eclipse. Everything went fine until the last gnome update. Now writing files with Eclipse ends in writing empty files, but there aren't any errors. Eclipse still shows the content of the files until i reopen them.
    When i'm writing files with other apps (vim, gedit) everything works normally?
    Does anybody have any suggestions?
    Thx

    Hello,
    I'm using gvfs to mount folders from our development server. I'm accessing these folders directly with Eclipse. Everything went fine until the last gnome update. Now writing files with Eclipse ends in writing empty files, but there aren't any errors. Eclipse still shows the content of the files until i reopen them.
    When i'm writing files with other apps (vim, gedit) everything works normally?
    Does anybody have any suggestions?
    Thx

  • File Adapter not writing file when processed from one node in a clustered environment

    In our environment, we have 4 server nodes running. We are using a file adapter to write file to a location in the server. the adapter is writing files when its processing data in all nodes except one.
    Below is the JCA File
    <connection-factory location="eis/FileAdapter" adapterRef=""/>
    <endpoint-interaction portType="Write_ptt" operation="Write">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
    <property name="PhysicalDirectory" value="/data/prd"/>
    <property name="FileNamingConvention" value="Sample.dat"/>
    <property name="Append" value="true"/>
    </interaction-spec>
    </endpoint-interaction>
    the File Adapter health is running OK. What would be the potential cause

    In our environment, we have 4 server nodes running. We are using a file adapter to write file to a location in the server. the adapter is writing files when its processing data in all nodes except one.
    Below is the JCA File
    <connection-factory location="eis/FileAdapter" adapterRef=""/>
    <endpoint-interaction portType="Write_ptt" operation="Write">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
    <property name="PhysicalDirectory" value="/data/prd"/>
    <property name="FileNamingConvention" value="Sample.dat"/>
    <property name="Append" value="true"/>
    </interaction-spec>
    </endpoint-interaction>
    the File Adapter health is running OK. What would be the potential cause

  • Errors when writing metadata to files on Windows Server

    Good day!
    I have an iMac running OSX 10.9 (Maverick) and Lightroom 5.2.
    My catalog is on the local iMac drive, and the images are on SMB shared drive (handled by Windows 2012 server).
    I decided to do the final layout of my album using InDesign, and for that I needed to access to images using Bridge. So selected all the images (the rated once...) and issue a Metadata/Save command.
    The system came back with errors on many of the files (such as Photos are read only, and unknown errors).
    Retrying to save the metadata on image that was flagged with an error usually (but not always) worked.
    I tried to select save the metadata for few (6) images in a time, many times it was ok, but sometimes, one or two of them failed (and retrying again usually solved the problem).
    It looks to me like a timing related issue.
    Any ideas?
    (After spending about an hour on this, I have exported the images to my local drive...). In general I don't have similar problems with other apps.
    Any ideas?
    Yuval

    I Yuval
    I'm experiencing more or less the same behavior (see Read-only error when writing metadata to file over network (Synology DS1315+ using AFP) ). For me however, the problem is more pronounced if I use the AFP protocol and is better (I think as you described) if I use SMB (all done on a Synology DS1315+). With SMB it most often works but in very rare cases I also get the "read only" message!
    Do you have solution to this? Or are you stuck as I am?
    Cheers, Chris

  • Error when Writing Metadata to Files in Bridge (Mac) but not in Bridge (PC)

    We get an error when writing metadata to files in Bridge (Mac) but not in Bridge (PC). In the same drive and folder, the PC can successfully write a keyword to a file on the PC, where the Mac returns an error. I have researched this at the Adobe Knowledgebase, but their answer seemed to indicate it was a global issue, and we don't see that behavior on the PC.
    The client is a Mac of course, and the server volume is a Windows share volume. The Mac is bound to AD, and the domain\username and username formats have both been tried when logging in, but you receive the error in both.
    Any help would be appreciated.
    Thanks!
    Rich Oliver

    Hi, I'm having the same problem using FreeNAS (which uses Samba and Netatalk in the backend), but I tried with both AFP and SMB on Mavericks and Yosemite, I still have the same issue.  I think it might be a timing issue with how lightroom interact with a slower write delay using network shares.  I suggest you also chime into this thread:  Lightroom 5 can't write metadata to DNG files   I really hope this is resolved as this is impacting my productivity as I moved my workflow to my Macbook with a shared NAS.

  • "Attempt to open locked file for writing, Result Code = -54" when importing

    I get this error box when importing audio files into a logic session over my network.
    +Attempt to open locked file for writing+
    +Result Code = -54+
    The finder is capable of copying the files over to the local machine, at which point I can successfully import them into my local logic session, but Logic is incapable of doing the same. Strange and annoying.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • Itunes 9.2.1.5 "Error when writing file C:\program files\apple software....

    Got an error message when installing itues 9.2.1.5 "Error when writing file C:\program files\apple software update\softwareupdate.exe you do not have admin right to read/write the menu." "寫入檔案時發生錯誤 C:\program files\apple software update\softwareupdate.exe 你沒有權限存取目錄"
    There is no "apple software update" folder in my C:\program files\
    I tried to uninstalled all apple related software, restart the computer and reinstall the itunes, I still get this error message.
    It appears that the installation of quicktime was successful.

    After the last update I get "QuickTime was not found" Error I have uninstalled and re-installed itunes 9.2.1.5. several times but the problem persists

  • Intermittent FileNotFoundException exception when writing files

    OS: Windows
    JRE 1.3.1
    I have an application that tries to write files to an existing folder (overwriting the files that are already there). This code is run very often at my site, and I�ve never had a problem. At some customer sites, we get an intermittent exception:
    java.io.FileNotFoundException (Cannot create a file when that file already exists).
    Each time it is run and the exception occurs, a different file takes the hit. Sometimes running against one folder works and against another doesn�t, on the same machine. I don�t think file protections are an issue (if I try to reproduce the problem by marking a file to be written over as read-only, I get an �access denied� exception on that file consistently).
    Of course, it is intermittent at just a few sites, and I can�t reproduce it myself.
    I�m wondering if it is possible that some other process (say a virus scan or back-up utility) is temporarily locking files in a way such that when I do my FileOutputStream.write() I catch this exception. Has anyone seen or heard of anything like this?
    Thanks,
    Paul

    Are you sure you are not accidently trying to open an output stream on a directory? From the API docs:
    FileOutputStream
    public FileOutputStream(File file)
                     throws FileNotFoundExceptionCreates a file output stream to write to the file represented by the specified File object. A new FileDescriptor object is created to represent this file connection.
    First, if there is a security manager, its checkWrite method is called with the path represented by the file argument as its argument.
    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 then a FileNotFoundException is thrown.
    Parameters:
    file - the file to be opened for writing.
    Throws:
    FileNotFoundException - 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
    SecurityException - if a security manager exists and its checkWrite method denies write access to the file.
    See Also:
    File.getPath(), SecurityException, SecurityManager.checkWrite(java.lang.String)Note the case where a FileNotFoundException will be thrown.
    - Saish

  • Error opening file for writing when installing

    I cannot install Flash on my Vista X64. I have tried running
    the downloadable install and the online install. Any time I try to
    run the install I get "error opening file for writing" when trying
    to write C:\Windows\SysWOW64\Macromed\Flash\Flash9d.ocx.
    I have uninstalled Fash first (it never worked anyway) and I
    have rebooted. I even tried rebooting in Safe Mode but no matter
    what I try, I cannot remove the existing Flash9d.ocx and installing
    will not overwrite the existing file.
    Even after uninstalling Flash and rebooting to safe mode,
    Windows reports that flash9d.ocx is in use. So why is the file in
    use after uninstalling?
    Any help is appreciated.
    Dale

    Well, I finally figured out the problem with mine today. Of
    course, I'd still like to know what nefarious purpose might be
    involved with the Flash activeX file being loaded in memory even
    after uninstall and reboot such that it cannot be removed from my
    PC even in Safe Mode.
    At least I got Flash working. I discovered that Flash was
    disabled in IE.
    In IE, go to Tools->Options->Programs and then Manage
    Add-Ons. In my case, the ShockWave Flash Object was set to
    disabled. I changed it to Enabled and I was able to install and use
    Flash properly. Now I am just not sure I want to.
    With the questionable practices of using the ActiveX control
    even after uninstall, and making the file un-removable, along with
    the extremely (in my opinion) dishonest practice of installing
    Google Toolbar with Flash, I am hoping that Microsoft's Silverlight
    puts Flash out of the market - and I'm no huge fan of Microsoft
    either. With the new practices from Adobe, they are, in my opinion,
    no better than any other spyware and malware purveyor on the market
    - right up there with Napster and the dozens of follow-on products
    that tricked users into installing unwanted software.

  • I/O Error when writing access Log buffer to file. error number: 28

    Hi,
    Oracle OracleAS Web Cache 10.1.2.3.0, Build 10.1.2.3.0 080201 is writing events like this:
    [alert 13215] I/O Error when writing access Log buffer to file. error number: 28
    I've looked for this alert and i've found this description:
    WXE-13215 I/O Error when writing access Log buffer to file. error number: %d
    Severity: alert
    Cause: I/O error happened when OracleAS Web Cache tried to write to the access log file.
    Action: Check the status of access log file. For example, see if the disk is full
    Anybody knows what "error number: 28" stands for? The logs are sended to other server and it seems that the disk size is ok.
    thanks!

    I tested again...it seems LabVIEW doesn't like the way I wrote the measurement files. I attached a set of VIs (ZIP-file) to give you a clue how it was done. When I try to save and read a file containing just plain DBLs from a 1D-Array (see attached file generating VI) it works perfectly well for large file sizes.
    So there might get something messed up by the way LabVIEW saved the measured data. You'll notice, that I (accidentally) left the "prepend array string size" input of "write to binary file" function unwired which means that the size information will be written as a type of header. Maybe this is the reason that it doesn't work as expected...
    Attachments:
    VibrationMeasurement.zip ‏76 KB
    generate_test_bin_data.vi ‏12 KB

Maybe you are looking for

  • WILL NOT SYNC WITH oUTLOOK 2003 (CALANDER)

    I updated my Palm software as suggested on this blog and now my Zire 72S will not sync all my calander. Some (not many) appts get on. I see an error  Outlook Calendar synchronization aborted  Duration: 868.7 seconds  Outlook Calendar  OLERR:05-000D  

  • Content conversion File Query.

    Hii, I wanted a little help with the content conversion. I have mentioned the parameters bleow: Document Name: MT_Vault_TRY RecordStructure: DT_DLY_DEPOSIT1.* Key Field Name: DT_DLY_DEPOSIT1.STRNBR parameters: DT_DLY_DEPOSIT1.fieldNames STRNBR,SLSDT,

  • Set a autocounter for file saving

    Hi I was wondering if anybody had a quick solution for autofile naming with a look-up so lab-view can deduce what the next file should be named. A counter would be the perfect example where if the last file stored in the directory was 001, the next f

  • BADI in Solution Manager

    Does anyone know a BADI in solution manager 4.0 to add some fields in document management table where we add in our project documentation. Thanks, Vinotha

  • Smartform generates large file attachment

    Hello Everybody, I am having the following issue... I have created a Smartform (one page) and when I email it as a PDF attachment the size of the e-mail is over 400K, which in our case generates and issue because of the number of e-mails that we are