Writing an file to a specified directory
I have an application in Tomcat. In this application i write data into an xml-file. When i check this, i see that the file is written in the bin directory of tomcat. Now I want to write this file into another directory, for example: /tomcat/webbaps/catalog/orders/order.xml
Can someone tell me how my code to place it in this specified directory looks like?
Thx !
When you specify the file name, prefix it by the directory you want it stored in. You didn't show any code that explains how you are doing it now, so I'm not showing you any code that might be irrelevant. There are many ways to write an XML file to disk.
Similar Messages
-
[SOLVED] C : How to block opening files "above" a specified directory?
SOLVED: Used
man 3 realpath
Hello Archers,
I have this one problem I've been struggling with. I kind of solved it but the solution's hackish.
My question is how do you prevent the opening of files "above" a specified directory? The reason behind this is that I'm writing a simple sharing server, something like Xyne's quickserve, but in C and with a GTK GUI. I'm using the libmicrohttpd library.
The program works this way: the user selects a port and a directory to be "served", and then he can access the files under the directory he chose. However, there obviously needs to be a way to prevent the user from opening files above the directory by using ".."'s for example.
For now, I simply plan on rejecting all queries containing ".." (http://github.com/houbysoft/quickshare/ … hare.c#L59), but that's obviously very imperfect -- and you could get around it if there is a symlink in the directory for example.
Any pointers will be very appreciated, thanks.
Last edited by y27 (2010-03-17 02:59:14)tavianator wrote:
man realpath wrote:BUGS
The POSIX.1-2001 standard version of this function is broken by design, since it is impossible to
determine a suitable size for the output buffer, resolved_path. According to POSIX.1-2001 a buffer
of size PATH_MAX suffices, but PATH_MAX need not be a defined constant, and may have to be obtained
using pathconf(3). And asking pathconf(3) does not really help, since, on the one hand POSIX warns
that the result of pathconf(3) may be huge and unsuitable for mallocing memory, and on the other
hand pathconf(3) may return -1 to signify that PATH_MAX is not bounded. The resolved_path == NULL
feature, not standardized in POSIX.1-2001, but standardized in POSIX.1-2008, allows this design
problem to be avoided.
So be careful to either pass resolved_path as NULL and bite the potential unportablilty bullet, or copy canonicalize_file_name or canonicalize_filename_mode from gnulib.
Yeah, I am passing NULL. -
How to print out all files in a specified directory
Now, I have some problem which prints out the entire content of all of the .txt files in a specified directory.
what method i can use?
Can anyone give me some examples?
Many ThanksRead the API for java.io.File, in particular the list and listFiles methods, and java.io.FilenameFilter.
-
Saving a file to a specified directory
Hello, how would i go about saving a file like from a JTextPane to anywhere the user selected from the JFileChooser menu. When I use the code below, it only gets stored in the directory where I run my program in.
import javax.swing.*;
import java.io.*;
import java.awt.*;
import package1.*;
import java.awt.event.*;
public class Test extends JApplet {
JTextPane tp = new JTextPane();
JButton b1 = new JButton("Save");
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
int rVal = fc.showSaveDialog(Test.this);
ObjectOutputStream oos = null;
String fname = null;
if(rVal == JFileChooser.APPROVE_OPTION) {
fname = fc.getSelectedFile().getName();
try {
oos = new ObjectOutputStream(new FileOutputStream(fname));
oos.writeObject(tp.getText());
oos.close();
} catch(Exception ex) {}
public void init() {
b1.addActionListener(al);
Container cp = getContentPane();
cp.setLayout(null);
tp.setBounds(80,80,420,420);
cp.add(tp);
b1.setBounds(10,10,80,40);
cp.add(b1);
public static void main(String[] args) {
Console.run(new Test(), 500,500);
I know I could of used a better way of saving the text but I just slapped that part together, I just really wanted to see where the file would end up. I know if I add, for expample, c:\\java\\ to the string in FileOutputStream it would store the file in the java directory. But I can't figure how to get a list a accessed directories. All I can get is the current one with the getCurrentDirectory() method.
Thanks for any help.Instead of:
fname = fc.getSelectedFile().getName();
use:
File file = fc.getSelectedFile();
FileOutputStream fos = new FileOutputStream( file ); -
Writing a file to an Oracle Directory
Hello,
I'd like to use a database trigger or PL/SQL to write a text file to to a directory on my database server. Is that possible? I know I could write a daemon that runs on the OS, but I'd lie to run it from the database itself.OK, figured it out. This was helpful: http://www.adp-gmbh.ch/ora/sql/create_directory.html
-
Saving a file in a specified directory
I have this network-application where I ask new users to enter their information. I want to be able to store this information in a file under that user's username. I want to make the directory for the user at my server and save the file inside that directory. I have tried several things but nothing have worked so far... Any ideas as to how I can create a directory from within a java program and save a file in that directory?
Thanks,
tiwari1. Create a File object for the directory
2. Create the directory on the filesystem with File.mkdir()
3. Write to a file in the directory. -
Writing the file to a specific directory on server using DATASET
Hello Friends
I know that using dataset command we can create a file, write to a file, read from a file etc.,
But by default it uses the directory DIR_SAPUSERS which is the ./ directory.
But this particular directory DIR_SAPUSERS also has other system related log files etc.,
Is there a way to make the command DATASET write to a user created directory instead of this ./ ??
Any suggestions or comments will be highly appreciated.
Thanks
RamIF NOT p_ufile IS INITIAL.
OPEN DATASET p_ufile FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
here p_ufile will contain the path where ever u need to place the file i.e. use specific path.... ex: "usr/sap/bin/interface" -
Copied a program from 4.1 to 8.2 recently and receive an error 7: File not found at open file+.vi. The program is built so a file dialog will pop up and ask for the destination of the file. Eventhough there is a file in the specified directory, an error is returned. Running open file+.vi by itself returns no error with the same file designation. Any clues?
noviceak,
Welcome to the NI Discussion Forums.
I created a quick VI in LabVIEW 4.1 that displays a file dialog and then passes that file path to "Read Characters from File.vi" (which in turn calls Open File+.vi). I then opened this file in LabVIEW 8.2 and ran it successfully (see code screenshot below).
When you say there is a file in the specified directory are you using the file dialog to browse to the directory or to select the specific file? Open File+.vi expects the path to a file rather than a directory - that is C:\folder\file.txt rather than C:\folder. You might also want to create an indicator or probe to see what path is being passed to Open File+ to ensure it is what you expect.
I feel like I should also say that in the days (years) inbetween LabVIEW 4.1 and 8.2 the file operation VIs have changed significantly. While the old Open File+.vi still lives in vi.lib for compatibility purposes we no longer recommend using it for new applications.
I hope this helps and again, welcome to the community.
Regards,
Simon H
Applications Engineer
National Instruments
http://www.ni.com/support/
Message Edited by Simon H on 01-18-2007 08:01 PM
Message Edited by Simon H on 01-18-2007 08:03 PM
Attachments:
LV4 File Dialog.png 3 KB -
How to view the file content from the directory? getting Error:ORA-21560
SQL> create directory READ_LOB_DIR as 'D:\Prj\Comm\Data';
CREATE OR REPLACE Procedure READ_FILE_LOB IS
-- Input Directory as specified in create directory
l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
-- Input File which is read word by word
l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
-- Separator Character between words is a BLANK (ascii = 32)
l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
-- Character at the end of the file is NEWLINE (ascii = 10)
l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
-- Pointer to the BFILE
l_loc BFILE;
-- Current position in the file (file begins at position 1)
l_pos NUMBER := 1;
-- Amount of characters have been read
l_sum BINARY_INTEGER := 0;
-- Read Buffer
l_buf VARCHAR2(500);
-- End of the current word which will be read
l_end NUMBER;
-- Return value
l_ret BOOLEAN := FALSE;
BEGIN
-- Mapping the physical file with the pointer to the BFILE
l_loc := BFILENAME(l_dir, l_fil);
-- Check if the file exists
l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
IF (l_ret) THEN
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' exists');
-- Open the file in READ_ONLY mode
DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
LOOP
-- Calculate the end of the current word
l_end := DBMS_LOB.INSTR(l_loc, l_seb, l_pos, 1);
-- Process end-of-file
IF (l_end = 0) THEN
l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
l_sum := l_end - l_pos - 1;
DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
EXIT;
END IF;
-- Read until end-of-file
l_sum := l_end - l_pos;
DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
l_pos := l_pos + l_sum + 1;
END LOOP;
DBMS_LOB.CLOSE(l_loc);
ELSE
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' does not exist');
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error:' || SQLERRM);
DBMS_LOB.CLOSE(l_loc);
END;
The Text file content is...
Copyright 1996,2001 Oracle Corporation. All Rights Reserved
This file contains installation instructions for installing the
Oracle8 ODBC Driver software.
It is divided into four parts:
o Part I: Summary of systems supported by Oracle8 ODBC client
software
Lists the platforms on which the Oracle8 ODBC Client software can
be installed.
o Part II: Oracle8 ODBC Driver software.
Describes the files, and installation prerequisites for the Oracle8
ODBC driver software.
o Part III: Exploding the kit onto your system
Describes how to explode the kit onto your system hard drive.
o Part IV: Installation Instructions
Describes how to install the Oracle8 ODBC driver.
Part I: Systems supported by the Oracle8 client software
You can install the ODBC client software on any of the following systems:
o Windows 2000
o Windows NT X86
o Windows 95
o Windows 98
The Oracle8 ODBC Driver provides support for ODBC connections
from Windows 2000, Windows NT, Windows 95, and Windows 98 systems
to Oracle databases.
o Part II: Oracle8 ODBC Driver software.
Refer to the following files for information about the Oracle8 ODBC Driver:
LICENSE.TXT - Oracle8 ODBC Driver License Agreement. Read carefully
before installing and/or using this product. Enclosed in
your software distribution kit.
SQORA.HLP - A Window's Help file which is the primary reference
manual for the Oracle8 ODBC Driver.
ODBCRelnotes.WRI - The release notes for the Oracle8 ODBC Driver
which contains information which may have not been
included in the Help file.
Installation Prerequisites
See the Oracle8 ODBC Driver release notes (ODBCRelnotes.WRI),
for a complete list of software products required and their versions.
Time Required
The installation of the Oracle8 ODBC Driver takes approximately 5
minutes. The actual time may be shorter or longer, depending upon
your hardware configuration.
Disk Space Required
The Oracle8 ODBC driver installation requires approximately 2
megabytes of available storage space. The space required depends upon
what files you already have installed. The installation procedure
checks to see if you have enough available disk space. If you do not,
the installation fails.
Part III: Exploding the Kit onto your system
Expand the self-extracting archive file onto your hard drive.
C:\> ORA8174.EXE
Part IV: Installation Instructions
Oracle8 ODBC Driver 8.1.7.4.0
This section assumes the following:
1. MS Windows 2000, Windows NT, Windows 95 or Windows 98 is running.
2. Oracle Universal Installer shipping with 8.1.7 has already been
installed on your system.
3. Part III has been completed.
Software fixes:
Refer to release notes (ODBCRelnotes.wri) for a complete list of
Software fixes.
Installation Instructions
Once the self-extracting archive file ORA8174.EXE has been
exploded it will create an installable directory structure
onto your hard drive. Run the Oracle Universal Installer from
your local drive.
1. On the screen "File Locations" use the "Browse" button of
the source path to choose the file 'products.jar' from the
folder that ORA8174.EXE was extracted to. Choose 'Next'.
2. You will receive a warning that some of the dependencies of
this product are not found in the staging area. This warning
is OK. The ODBC driver depends on the Net8 Client being already
installed on the system. Answer 'Yes' to continue.
Oracle is a registered trademark of Oracle Corporation.
Microsoft, MS are registered trademarks of Microsoft Corporation.
Microsoft Windows, Windows NT, Windows 95, Windows 98 and Open Database
Connectivity are trademarks of Microsoft Corporation.
All other trademarks and registered trademarks are the property
of their respective owners.
The output was...
File testfile.txt in Directory READ_LOB_DIR exists
Copyright
1996,2001
Oracle
Corporation.
All
Rights
Reserved
This
file
contains
installation
instructions
for
installing
the
Oracle8
ODBC
Driver
software.
It
is
divided
into
four
parts:
o
Part
I:
Summary
of
systems
supported
by
Oracle8
ODBC
client
Error:ORA-21560: argument 2 is null, invalid, or out of range
I want to diplay/view as per file content format from the file under that specified directory.
Have any other method / any help or suggestions would be really appreciated.I changed the code like...
CREATE OR REPLACE Procedure READ_FILE_LOB_tmp IS
-- Input Directory as specified in create directory
l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
-- Input File which is read word by word
l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
-- Separator Character between words is a BLANK (ascii = 32)
l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
-- Character at the end of the file is NEWLINE (ascii = 10)
l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
-- Pointer to the BFILE
l_loc BFILE;
-- Current position in the file (file begins at position 1)
l_pos NUMBER := 1;
-- Amount of characters have been read
l_sum BINARY_INTEGER := 0;
-- Read Buffer
l_buf VARCHAR2(4000);
-- End of the current word which will be read
l_end NUMBER;
-- Return value
l_ret BOOLEAN := FALSE;
BEGIN
-- Mapping the physical file with the pointer to the BFILE
l_loc := BFILENAME(l_dir, l_fil);
-- Check if the file exists
l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
IF (l_ret) THEN
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' exists');
-- Open the file in READ_ONLY mode
DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
LOOP
-- Calculate the end of the current word
l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
-- Process end-of-file
IF (l_end = 0) THEN
EXIT;
END IF;
-- Read until end-of-file
l_sum := l_end - l_pos;
DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
l_pos := l_pos + l_sum + 1;
END LOOP;
DBMS_LOB.CLOSE(l_loc);
ELSE
dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
' does not exist');
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error:' || SQLERRM);
DBMS_LOB.CLOSE(l_loc);
END;
Now its working fine with one addtional line...
The file content is...
This is My Content
This is My Content
This is My Content
This is My Content
This is My Content
But The output was...
File testfile.txt in Directory READ_LOB_DIR exists
This is My Content
This is My Content
This is My Content
This is My Content
This is My Content
here, i want to delete that additonal line...? -
I was trying to download iTunes on my computer, and while doing so, I got this message: Error writing to file: C:/Program Files (x86)/Common Files/Apple/Apple Application Support/Apple Versions.dll. Verify that you have access to that directory. I have downloaded iTunes numerous times and I have never had this problem. If anyone knows what's going on, I would really appreciate the help.
Well, there's definitely a mac and a Windows version. And you're at the right page. I think the problem is that someone forgot (or decided not to) to update the text at teh bottom of the page to have Mac and Windows.
Just push the button, you'll get the Mac update no problem.
Regards,
Bentley Wolfe
Senior Support Engineer, Flash/Flash Player/Digital Editions
Adobe -
SharePoint Designer 2013 after installation getting error with runtime i.e. error writing to file Microsoft.SharePoint.Client.Runtime.Local.Resources.dll Verify that you have access to that directory
after retry..again SharePoint Designer requires the following component require to install Microsoft.NET framework version 4 i have downloaded and try to installed but fail not work please answer what to do?
Thanks and Regards, Rangnath MaliHi Rangnath,
For running SharePoint Designer 2013, you need to install Microsoft .NET 4.0 Framework or higher.
Please uninstall the Microsoft .NET 4.0 Framework, and install it again. After that, reboot your machine.
Best Regards,
Wendy
Wendy Li
TechNet Community Support -
When i try to install iTunes in my Windows 7, this error message apear "Error while writing to file: C: \ Program Files (x86) \ iTunes \ iTunes.Resources \ el.Iproj \ iTunesExtrasDownload.png. Make sure you have access to this directory." Someone help me!!
That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
XP instructions in the following document: How to perform disk error checking in Windows XP
Vista instructions in the following document: Check your hard disk for errors
Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards? -
I need help in trying to install I Tunes,,,after multiple attempts I have now pulled all my hair out,and I am without I Tunes,,,I have tried everything ,and all the ideas that I have found in trying to seach the reason for my problem.it will download quick time,,,it gets about half way through I Tunes and I get a error message that says...........Error writing to File C /program files x86 itunes .tunes exc.verify you have access to that directory......I need the wisdom of any and all that are smarter than I about this issue.........I would appreciate any and all help ..thank you....
iOS: Unable to send or receive email
http://support.apple.com/kb/TS3899
Can’t Send Emails on iPad – Troubleshooting Steps
http://ipadhelp.com/ipad-help/ipad-cant-send-emails-troubleshooting-steps/
Setting up and troubleshooting Mail
http://www.apple.com/support/ipad/assistant/mail/
Server does not allow relaying email error, fix
http://appletoolbox.com/2012/01/server-does-not-allow-relaying-email-error-fix/
Why Does My iPad Say "Cannot Connect to Server"?
http://www.ehow.co.uk/info_8693415_ipad-say-cannot-connect-server.html
iOS: 'Mailbox Locked', account is in use on another device, or prompt to re-enter POP3 password
http://support.apple.com/kb/ts2621
iPad Mail
http://www.apple.com/support/ipad/mail/
Configuration problems with IMAP e-mail on iOS with a non-standard SSL port.
http://colinrobbins.me/2013/02/09/configuration-problems-with-imap-e-mail-on-ios -with-a-non-standard-ssl-port/
Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
Or this - Delete the account in Mail and then set it up again. Settings->Mail, Contacts, Calendars -> Accounts Tap on the Account, then on the red button that says Remove Account.
Cheers, Tom -
I recieve the following error message when trying to install Quicktime for Windows "Error writing to file C:/Program Files/QuickTime/QTSystems/QuickTimeCheck.ocx. Verify that you have access to that directory." I just trying to get the latest version of iTunes. Thanks
"Error writing to file C:/Program Files/QuickTime/QTSystems/QuickTimeCheck.ocx. Verify that you have access to that directory."
That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
XP instructions in the following document: How to perform disk error checking in Windows XP
Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards? -
Itunes will not install. I get the error message "Error writing to file: C:\Program Files\Common Files\Apple\Mobile Device Support\com.apple.IE.client_main.dll Verify that you have access to that directory."
That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
XP instructions in the following document: How to perform disk error checking in Windows XP
Vista instructions in the following document: Check your hard disk for errors
Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?
Maybe you are looking for
-
Hi guys, No matter how many times i try and re-install creative cloud, i cannot access my dreamweaver... On the apps tab it simply shows me a grey triangle and "Download Error - contcat customer support." I have searched the forums and have found not
-
Music not playing in music app on IPAD 2
My iPad 2 is just not playing music in the music app. I can click play, it says it is playing but the bar doesnt move to indicate playback and there is no sound. I've tried closing the app and restarting the device. Does anyone have any ideas?
-
Reasons why PA doesn't balance to the Ledger
Hello All, I am basically a technical person, but i dont know how it came to be that this became my concern. I would just like to get feedbacks on the reasons why PA will not balance to the Ledger. In this company that I'm a consultant right now, hav
-
Error Dump Creating a Transformation Object
Hi all: I have NW2004s in my box. I have the following error when trying to create a Tranformation Object (function "Create Transformation" on a Data Source).: "Make sure that the OCXs ICDataFlow.ocx and wdbdadpt.ocx are installed on your computer.
-
Merging MP4 clips and saving as MP4 in PE8
In PE8, I imported several MP4 clip segments that are part of an entire MP4 movie. I placed them in sceneline view. The only option I could save it was a PE file and I would have to watch it using PE. The clip scenes played back slow and seemed di