Creating a temporary file in the user computer

Hi everyone,
I want to create a new file using:
File folder = new File(folderString);
when folderString should be a folder where all temporary files of the user are saved (its a dynpage code).
So I found the following code in <b>JavaScript</b>:
var  cTemporaryFolder = 2,tmpdir='';
var fso;
fso     = new ActiveXObject('Scripting.FileSystemObject');
var fso;
tmpdir     = fso.GetSpecialFolder(cTemporaryFolder);
But how do I combine the code with the statement
File folder = new File(folderString);
(I eventually need: folderString = tmpdir - but one variable knows <b>java</b> and the other <b>javascript</b>)
Thanks so much.
I promise to award points...
Ruthie.

Hi Ruthie,
Try out this code
try{
// Create a temporary file object
File f = new File("d://TestTemp");
File tempFile = File.createTempFile("mail", "temp",f);
System.out.println("Created temporary file: " + tempFile + "\n");
// Delete temp file when program exits
tempFile.deleteOnExit();
// Write to temporary file
BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
out.write("TEMP FILE: " + tempFile);
out.close();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Press any key");
br.read();
System.out.println("Temp File will be deleted");
catch(IOException e) {
e.printStackTrace();
Now, the temp file will be created in d:\TestTemp\ folder. Before pressing any key just check in this folder. You will see the temp file. Pressing any key will exit the program. After this check the d:\TestTemp\ folder, the tempfile will be deleted.
Regards,
Uma

Similar Messages

  • File Adapter-Creating a temporary file

    Hi,
    I got an requirement to place only completed file(With 100% data) in the target directory. So  i need to gather the data in  a temporary file first before final file is put on the target directory. I know we have an option in the File adapter (Put File). What i need is, where the temporary file is created?  do we need to delete these  temporary file?  and How to test this requirement?
    Thanks in advance.
    Regards
    Sreeni

    HI Sreeni
    If you use Temporary file under put file XI wil create a temporary file at the target location only.
    But when your requirement is to create file why you are looking for temperory file. Just use Create and it will create a final file.
    write mode : directly
    Use empty file handling as Ignore
    Thanks
    Gaurav

  • Okay, so I try to download and every time it says "There was an error creating a temporary file that is needed to complete the installation".   Anyone know how to fix this?

    Okay, so I try to download and every time it says "There was an error creating a temporary file that is needed to complete the installation".
    Anyone know how to fix this?
    Please help. I can't get it to work. I've tried uninstalling and it says the same thing. Is there anyway anyone can help me?

    HELP!!!! PLEASE!!!!!

  • Why the error "unable to create unique temporary file" ?

    Hi,
    I've created a very simple zone on s10_69. The global zone is a default Solaris install, nothing added. When installing the local zones I get theses error messages:
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/100dpi/fonts.dirMMaypm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/75dpi/fonts.dirNMaypm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/F3bitmaps/fonts.dirOMaypm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/misc/fonts.dirPMaypm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirSMaypm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirUMaypm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/server/etc/OWconfigjha4tm>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/sfw/lib/mozilla/.pkg_update_stampepaybn>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/75dpi/fonts.dirgOa4Gn>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/F3bitmaps/fonts.dirhOa4Gn>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/Type1/fonts.diriOa4Gn>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/misc/fonts.dirjOa4Gn>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/misc/fonts.alias.alllOa4Gn>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirfGaWoo>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirhGaWoo>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/server/etc/OWconfigL2aqZo>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirgPaW7o>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirhPaW7o>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/xil/config1Faipp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/xil/config2_aWtp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirEhaywp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirGhaywp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirsVaqAp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.diruVaqAp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/bin/wscompilejbaWAp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/bin/wsdeploykbaWAp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/F3/fonts.dirioaqBp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/server/etc/OWconfigLYaaCp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dir10a4Dp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirZAaOEp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dir1AaOEp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirhUaqFp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirjUaqFp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirDNaGGp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirFNaGGp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.diryVaGLp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirAVaGLp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirdtaGMp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirftaGMp>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/100dpi/fonts.dirgZaWKq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/75dpi/fonts.dirhZaWKq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/F3/fonts.diriZaWKq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/Speedo/fonts.dirjZaWKq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/75dpi/fonts.alias.alllZaWKq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/F3/fonts.alias.allmZaWKq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/encodings/encodings.dirlqaGLq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/lib/X11/fonts/TrueType/ttmap/ttmaps.dirnqaGLq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/asadminsTaGNq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/pointbase/tools/serveroption/startcommander.shbHayPq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/pointbase/tools/serveroption/startconsole.shcHayPq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/pointbase/tools/serveroption/startserver.shdHayPq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/pointbase/tools/serveroption/stopserver.sheHayPq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/openwin/server/etc/OWconfigt2aGYq>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/appclienta2aOyr>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/asantb2aOyr>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/capture-schemac2aOyr>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/deploytoold2aOyr>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/jspce2aOyr>
    pkgadd: ERROR: unable to create unique temporary file </zones/zone2/root/usr/appserver/bin/package-appclientf2aOyr>and more like these.
    Any ideas why ?
    The files are all there after installation, without the temporary names. So it doesn't seem to be a big problem...
    Thanks,
    Vlad.

    I don't have the bug number handy but I'm quite certain this was
    resolved in one of the post-s10_69 builds. Please download the
    official Solaris 10 initial release and by all means, let us know if you
    continue to see this issue during zone installation.

  • MSB5003: Failed to create a temporary file.

    All of a sudden we are getting this error on the build computer.  We have searched the forums and followed other resolutions (delete the Temp directory) but still it continues.
    The full error message:
    [Any CPU/Debug] C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets(135,9): error MSB6003: The specified task executable "Csc.exe" could not be run.
    MSB5003: Failed to create a temporary file. Temporary files folder is full or its path is incorrect. The file exists.
    Any ideas what to try next?

    Not permissions.  Not TEMP path name. 
    After some research we ran Process Monitor during the build.  Turns out we used up all of the temporary file names... LOL! 
    Tmp file names in Vista, and maybe others, have the format tmp####.tmp, where #### is 0x0000 to 0xffff.   When we looked in the Temp directory we found over 65,000 TMP files.  We are guessing that CSC creates these files but does not remove them.  After so many thousands of builds, we ran out of names.  We thought they were gone when we ran Disk Cleanup, but MSBUILD uses the administrator account while we were cleaning from a user account.
    Might be nice if CSC deleted it's TMP files...
    There ya go, add that to your bag of tricks... :)

  • Failed to create a temporary file in directory C:\PROGRA~2\: Method GetTempFileName

    I have Mcafee anti-virus and currently purchased a new package, so I decided to reinstall the software as it would not verify through the other product package.
    So I unistalled and tried to reinstall the software and now everytime I try to install any software it either:
    (1) does not run the installation process or
    (2) an error message pops up saying: "failed to create a temporary file in directory C:\PROGRA~2\: Method GetTempFileName"
    I am really stuck as I now basicaly can't run installations and cannot retrieve Mcafee either.
    I have an HP Elitebook 8440p.
    Any ideas??

    Not permissions.  Not TEMP path name. 
    After some research we ran Process Monitor during the build.  Turns out we used up all of the temporary file names... LOL! 
    Tmp file names in Vista, and maybe others, have the format tmp####.tmp, where #### is 0x0000 to 0xffff.   When we looked in the Temp directory we found over 65,000 TMP files.  We are guessing that CSC creates these files but does not remove them.  After so many thousands of builds, we ran out of names.  We thought they were gone when we ran Disk Cleanup, but MSBUILD uses the administrator account while we were cleaning from a user account.
    Might be nice if CSC deleted it's TMP files...
    There ya go, add that to your bag of tricks... :)

  • "Couldn't create destination temporary file:Permission denied"

    I am running the latest version of Final Cut Server on a Mac Pro Tower running Mac Server 10.6.X.
    I keep getting 2 Error messages every time my users are trying to send content to the server via Final Cut Server client application:
    (1) "Broken Pipe" and (2) "Couldn't create destination temporary file:Permission denied"
    Anybody have any Ideas on how I could correct this?
    Thanks

    Can you elaborate on what you did to fix this? I am getting the same error. Everything was fine about a week ago. I tried repairing the disk permission in Disk Utility.

  • REP-0118 Unable to create a temporary file in "Windows 7 "

    We are using Report Builder Version 6.0.8.24.0 and Windows7 32 bit operating system, here
    While Running a Report through form i am getting this below
    error.
    REP-0118 Unable to create a temporary file*
    But while running the same report in a windows 98 or windowsXp PC
    i dont get this error.
    What might be the problem.
    pls advice the solution....
    thanks in Advance...
    Stalin...

    try this..
    REP-118: Unable to create a temporary file.
    Case 1: The environment variable that determines in what directory to create temporary files is set to an invalid directory.
    Case 2: There is not enough free space on the disk to create the temporary file.
    Case 3: A temporary file that cannot be modified already exist
    In regedit under branch hkey_local_machine/software/oracle/<oracle home> 
    I have changed the variable REPORTS_TMP. I changed the value for this to c:\reports_tmp
    or you can use something like this where you want Oracle reports to create temp files. Hope this helps

  • How can I know the name of the file that the user has currently open ?

    Hello
    I'm developing a module for x3dv.
    http://hiperia3d.blogspot.com/search/label/X3DV%20Module%20For%20Netbeans
    I am going to add a button to open the files when I click it.
    I just need to know how can I know the name of the file that the user has currently open in the editor. What variable holds it in Netbeans?
    Thank you
    Jordi

    If you are using the JFileChooser to open the document, I would create another class with this included:
    //initiate class variables
    private File f;
    //create JFileChooser
    JFileChooser fc = new JFileChooser();
    fc.setMultiSelectionEnabled(false);
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY)
    //set the chooser to initialise File f with the file selected
    int status = fc.showOpenDialog(null);
    if (status == JFileChooser.APPROVE_OPTION)
         f = fc.getSelectedFile();
    public File getFile()
         return f;
    }

  • Is it possible to create a control file without the datafiles

    Hi All,
    Is it possible to create a control file without the datafiles?
    on any OS or DB version
    regards,
    sachin

    if I understand properly:
    - you have a script to recreate the controlfile
    - you have all of your database files backed up except your controlfiles
    This should work as this is how we sometimes refresh dev databases:
    1) restore the copies of the database files
    2) recreate the controlfile
    3) recover the database files to the desired point in time (if hot backup or archivelogs are available, otherwise, it would be as of the time of the backup)
    4) add temp files to temporary tablespace(s)
    The simpler solution would be to backup your controlfile at the same time as your datafiles (RMAN or o/s copy).
    I hope I understood your question properly.

  • 7.7 upgrade:  Error:  There was an error creating a temporary file

    *I get the following error when trying to upgrade to 7.7*
    +"There was an error creating a temporary file that is needed to complete this installation"+
    *When I got to launch iTunes ver 7.6.1.9 I get the following message*
    +"The registry settings used by iTunes drivers for importing and burning CDs and DVDs are missing. This can happen as a result of installing other CD burning software. Please reinstall iTunes. iTunes was not properly installed. If you want iTunes to retrieve CD information from the internet, you need to reinstall iTunes"+
    The problem I have is I cannot uninstall iTunes using ADD/Remove Programs nor can I upgrade.
    Anyone have any suggestions?
    BTW, when I launch iTunes it works but I have not hooked my iPOD up yet for fear it will erase.
    Thanks!
    Message was edited by: Slattern

    Ensure antivirus is disabled. McAfee interfered with my iTunes installer resulting in this error. When I temporarily disabled McAfee, the installer completed successfully.

  • Creating 2 separate libraries on the same computer

    So my sister just got her first iPod (nano chromatic), I have had mine for two years (nano second generation). I would like to know if it is possible to create two separate libraries on the same computer. If someone could also please tell me how to do that, that would be awesome. Thank you all so much!
    -Auri

    To create or access a second (or more) library, hold down the Shift key in Windows when launching iTunes. In the resulting dialogue you will get the option to create a new library or navigate to the other Library.
    Note: You can only have one Library open at a time and iTunes will default to the last library opened if you don't use the keyboard command to choose one. This can prove tricky when using multiple iPods, if you don't use the keyboard command you can risk syncing to the wrong library: Using multiple iTunes libraries -Windows
    Another option is to create a separate Windows User account for each person on your PC. Different accounts by definition would give you completely separate libraries. Each account has it's own iTunes folder, Library and iTunes Music folder and you load it with CDs etc just as you did with your original one. The iPod can be set to update however the owner chooses, sync all, manual or sync specific playlists
    I don't use Windows so I can't give you a step by step on that one, however I can point you to another web page which should help you out. You can read about Windows user accounts here: Create and customize user accounts in Windows XP

  • Arlington Historical Society wants to give its visitors the ability to look at our IPhoto files on the Apple computer in our office, but NOT be able to modify them in any way.  How can we do this?

    Arlington Historical Society wants to give its visitors the ability to look at our IPhoto files on the Apple computer in our office, but NOT be able to modify them in any way.  How can we do this?

    Thanks. We want visitors to browse through our historical photos in any of the ways iPhoto will allow them, including slide shows, but also searching for photos by key word and viewing them along with the comments we have entered on that photo.
    I was beginning to think iPhoto had no capability to limit users to certain functions.
    I wonder if the use of Apple's sharing files function would help. I have read that it is possible to share files with others, and to limit their use to viewing only, but I don't know how to do this.

  • Can not create a temporary file when trying to open an attachment

    Hi just got the new BB Z10. Just upgraded the software and now I can not open any attachement anymore. Error , cannor create a temporary file....,
    Anybody experienced same problem?

    Try to restart the phone by holding the top button for about 3 seconds, and then the restart at the bottom right  of the screen
    I f that fails, keep the phone on, then pull the battery out, wait for about a minute or two and then re-insert
    Using the Playbook and the Z10 and the Z30 and loving them
    Martin

  • Create a temporary file..

    Hi guys,
    i've an easy question for you. I've a jsf application, when i click on a button a method starts that creates a temporary file, run an applet that loads this file and when the applet ends the temporary file has to be deleted.
    What is my problem?
    I've tried to create the temporary file with
    String y="good";
    File w=File.createTempFile("giu",".txt");
              BufferedWriter b;
              b = new BufferedWriter(new FileWriter(w));
    b.write(y);i've searched a giu.txt file but it doesn't exists!!!
    Please help me to understand where is my error,thanks

    thanks guys for your help but it doesn't work!!
    This is my simple method
    public String go()throws IOException{
              try {
                   System.out.println("hi");
                 // Create temp file.
                 File temp = File.createTempFile("aaaaa",.txt );
                 System.out.println("hi1");
                 // Write to temp file
                 BufferedWriter out = new BufferedWriter(new FileWriter(temp));
                 System.out.println("hi2");
                 out.write("aString");
                 System.out.println("hi3");
                 out.close();
             } catch (IOException e) {
                  System.out.println("hi100");
              return "greeting";
         }when i run it all try code is correctl executed without throwing exceptions but aaaaa.txt isn't created!!
    How can i do?
    Please help me

Maybe you are looking for

  • IOS 8 - Where did option to add song to a Playlist Go?- Did they remove this?

    I used to be able to add a song to a playlist with iOS 7.  I've spent hours searching for a way to do this in iOS 8 with no luck,   Does anybody know how to do it?  I can't find a single example using Google!  It's driving me nuts.  Did they take it

  • How to add a new column to specific position

    Hi, How to add a new column to specified position in a existing table. I have using the oracle database 10g. This below code is not working in oracle 10 g example: ALTER TABLE EMPLOYEE ADD DEPT NUMBER FIRST: ALTER TABLE EMPLOYEE ADD DEPT NUMBER AFTER

  • Original System for transformations and DataSources

    Dear All, I have imported all DataSources and transformations from DEV box into QAS box. Transports ended without errors and they are working fine. I have the following questions, when check the Object Directory Entry (RSA1->Extras-> Object directory

  • Trying to update iphone to Ios 5

    I first updated my itunes as requested, then restarted computer, and then set to download the new update. It has downloaded fine but when I am getting ready to update it starts the back up for my phone and stops not even 25% in and states an error ha

  • Importing the Ravenna Tutorial Site

    Hello, I was able to import the RVH Tutorial Site and everything went as planned, EXCEPT after it installs then I go and run the Indexer because the doc says that needs to be done before you can view the site in teh browser. Well I went in to the Rep