How to read all files' name in a directory and store in a string array?
as title
One possibility is to use the listFiles() method, using recursion if you want the files in the sub-directory also. Check API documentation for java.io.File.
Similar Messages
-
How to read all files under a folder directory in FTP site
Hi Experts,
I use this SQL to read data from a file in FTP site. utl_file.fopen('ORALOAD', file_name,'r');
But this need to fixed file name in a directory. However, client generate output file with auto finename.
SO do we have any way to read all file by utl_file.fopen('ORALOAD', file_name,'r');
We need to read all file info. because client claim for security issue and does not to overwirte output file name,
we must find a way to read all file in output directory.
Thanks for help!!!
JimIf you use Chris Poole's XUTL_FTL package, I believe that contains functions that allows you to query the directory contents.
http://www.chrispoole.co.uk/apps/xutlftp.htm
Edited by: BluShadow on Jan 13, 2009 1:54 PM
misread the original post -
Newbie question - How to read all files for a backup
Hello all,
I have two users on my iMac. I am an administrator and the other user is a Standard user.
From my account, I wish to run backup software that will backup the entire "User" directory. The problem I am having is that when I run the backup software (fyi: iBackup),
it complains that it cannot read the files in the other user's account.
I notice that when I browse to the other user's account, all the directories in their home folder are locked.
How can I run my backup software so that it can read all files in the User directory?
Thank you kindly!
Jeff
17" iMac Core Duo Mac OS X (10.4.6)Hi kneecarrot !
I don't know if this will suit your needs, but one easy way of backing up other user's stuff is via the terminal . If you have an admin accountm just use:
sudo ditto -rsrcFork /Users /Volumes/"nameof_anotherharddrive"/Users
This will perform an identical clone of all your users home direcories for backup purposes. To restore the bkd'up files, just reverse the lines:
sudo ditto -rsrcFork /Volumes/"nameof_anotherharddrive"/Users /Users
ATTENTION: Be aware that it will restore the files to the exact structure and contents it was when backed up, erasing all new and modified files!! You may however copy just the files/folders you want to recover, e.g.:
sudo ditto -rsrcFork /Volumes/"nameof_another_harddrive"/Users/"usera"/Documents /Users/"user_a"/Documents
IMPORTANT: As with all terminal commands... be careful, think twice and double-check the syntax. You may want to test with non-critical stuff or demo user accounts first.
Good luck,
Michael
MacBook Pro Mac OS X (10.4.6) 2 Gig RAM -
Listing of all file names in a directory
Hello everyone,
Is there a way to get the listing of all file names in a directory
pointed by an entry in dba_directory in oracle into a collection in
pl/sql procedure.
Thank you.
Tuncaythis is the same problem I am trying to solve now. I found some ehlp in Tom Kyte articles on java stored procedures.
create global temporary table DIR_LIST
( filename varchar2(255) )
on commit delete rows;
create and compile java source named "DirList" as
import java.io.*;
import java.sql.*;
public class DirList
public static void getList(String directory)
throws SQLException
File path = new File( directory );
String[] list = path.list();
String element;
for(int i = 0; i < list.length; i++)
element = list;
#sql { INSERT INTO DIR_LIST (FILENAME)
VALUES (:element) };
create procedure get_dir_list( p_directory in varchar2 )
as language java
name 'DirList.getList( java.lang.String )';
then you call in your pl/sql and fill your collection from the DIR_LIST table:
get_dir_list('the name of the directory' );
---then you fill the collection by fetching the DIR_LIST table
good luck,
Florin -
How to read dynamic file names in RSEINB00?
Hi, ABAP Gurus,
actually I'm a PI Consultant. Now I have a scenario to use the report RSEINB00.
In the Applicaton Server i put ASCII IDocs with the following name convension: <static name>+<time stemple>:
SAPIDOC20111127-224128-952.txt
SAPIDOC20111127-224129-115.txt
I created a new port in WE21 and the Outbound file and Inbound fiel tabs haben the same configration:
physical directory: /ABC/DEV100/inbound/
Function module: EDI_PATH_CREATE_DATE_TIME
Inbound file: SAPIDOC.txt
To execute the report RSEINB00 I must give the complete file name and port. It is not convenient.
My target is, with a job to run RSEINB00 once daily to read all files with name "SAPIDOC + <time stemple>" full automatically.
Is it possible? how to figure it out?
thanks a lot in advance! <removed by moderator>.
Regards
Rene
Edited by: Thomas Zloch on Nov 29, 2011 5:23 PMwith the extension of the standard report RSEINB00 i solved this problem. here is some code:
DATA:
dir_name LIKE epsf-epsdirnam,
file_mask LIKE epsf-epsfilnam,
g_message_fields LIKE edimessage.
DATA:
filename LIKE edi_path-pthnam,
filename2 LIKE edi_path-pthnam,
myport TYPE EDIPO-PORT.
DATA: h_EDIDC LIKE EDIDC.
DATA:
wa TYPE file_table.
DATA:
t_dir_list TYPE STANDARD TABLE OF epsfili WITH HEADER LINE,
itab TYPE table of file_table WITH HEADER LINE.
*The directoy, where the Markant ASCII IDocs are droped by XI.
dir_name = '<.../inbound>'.
*File mask of ASCII IDocs.
file_mask = 'XYIDOC.'.
*File port.
myport = '<Portname>'.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = dir_name
file_mask = file_mask
TABLES
dir_list = t_dir_list
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE e600(fr) WITH 'No ASCII IDoc exits'.
ENDIF.
"BREAK-POINT.
*The old ASCII IDocs are stored in a dataset and copied with new file name sent_<original name>
LOOP AT t_dir_list.
CONCATENATE dir_name '/' t_dir_list-name INTO filename.
CONCATENATE dir_name '/sent_' t_dir_list-name INTO filename2.
open dataset filename for input in text mode.
open dataset filename2 for output in text mode.
if sy-subrc = 0.
do.
read dataset filename into wa.
if sy-subrc <> 0.
exit.
endif.
transfer wa to filename2.
append wa to itab.
enddo.
endif.
close dataset filename.
*loop at itab into wa.
transfer wa to filename2.
*endloop.
close dataset filename2.
PERFORM inbound_processing USING filename.
ENDLOOP.
*& Form inbound_processing
FORM inbound_processing USING filename TYPE edi_path-pthnam.
do inbound processing from file
CALL FUNCTION 'IDOC_INBOUND_FROM_FILE'
EXPORTING
file_name = filename
port = myport
EXCEPTIONS
file_open_failed = 1
marker_to_be_deleted = 2
read_file_failed = 3
idoc_not_stored = 4
file_delete_failed = 5
marker_modify_failed = 6
event_create_failed = 7
first_record_invalid = 8
invalid_record = 9
OTHERS = 10.
IF sy-subrc <> 0.
fill message fields for exception handling from system fields
MOVE-CORRESPONDING sy TO g_message_fields.
error handling using the 3.0 business workflow
CALL FUNCTION 'IDOC_ERROR_WORKFLOW_START'
EXPORTING
docnum = 0
eventcode = 'EDIM'
mess = g_message_fields
EXCEPTIONS
no_entry_in_tede5 = 0
error_in_start_workflow = 0
OTHERS = 0.
do not care for exceptions here
COMMIT WORK.
append message for RFC
MESSAGE ID g_message_fields-msgid
TYPE 'A'
NUMBER g_message_fields-msgno
WITH g_message_fields-msgv1 g_message_fields-msgv2
g_message_fields-msgv3 g_message_fields-msgv4.
ENDIF.
ENDFORM. "inbound_processing -
How to Read all files inside resource Folder inside Jar?
I have a Jar file,,,, The program reads for resource files in the resource folder inside the Jar. I want my program to read all files inside this folder without knowing the names or the number of files in the folder.
I am using this to make an Applet easy to be updated with spicific files. I just want to add a file inside the resource folder and Jar the program and automatically the program reads what ever is in there!!
I used the File class to get all file names inside the resource folder. it works fine before Jarring the program. After I jar I recieve a URI not Herarichy Exception!!
File fold=new java.io.File(getClass().getResource(folder).toURI());
String[] files=fold.list();
I hope the question is clear!!How to get the directory and jar file that you class resides in:
// returns path and jarfile (ex: /home/mydir/my.jar)
public String getJarfileName()
// Get the location of the jar file and the jar file name
java.net.URL outputURL = YourClass.class.getProtectionDomain().getCodeSource().getLocation();
String outputString = outputURL.toString();
String[] parseString;
int index1 = outputString.indexOf(":");
int index2 = outputString.lastIndexOf(":");
if (index1!=index2) // Windows/DOS uses C: naming convention
parseString = outputString.split("file:/");
else
parseString = outputString.split("file:");
String jarFilename = parseString[1];
return jarFilename;
}If your my.jar was in /home/mydir, it will store "/home/mydir/my.jar" in jarFilename.
note: getLocation returns "file:/C:/home/mydir/my.jar" for Windows/DOS and "file:/home/mydir/my.jar" for windows, thus why I look for the first and last index of the colon so I can correctly split the string.
If you want to grab a file in the jar file and get an InputStream, do the following:
import java.io.*;
import java.util.Enumeration;
// jar stuff
import java.util.jar.*;
import java.util.zip.ZipEntry;
public class Jaris
private JarFile jf;
public Jaris(String jarFilename) throws Exception
try
jf = new JarFile(jarFilename);
catch (Exception e)
jf=null;
throw(e);
public InputStream getInputStream(String matchString) throws Exception
ZipEntry ze=null;
try
Enumeration resources = jf.entries();
while ( resources.hasMoreElements() )
JarEntry je = (JarEntry) resources.nextElement();
// find a file that matches this string from anywhere in my jar file
if ( je.getName().matches(".*\\"+matchString) )
String filename=je.getName();
ze=jf.getEntry(filename);
catch (Exception e)
throw(e);
InputStream is = jf.getInputStream(ze);
return is;
// for testing the Jaris methods
public static void main(String[] args)
try
String jarFilename=getJarfileName();
Jaris jis = new Jaris(jarFilename); // this is the string we got from the other method listed above
InputStream is=jis.getInputStream("myfile.txt"); // can be used for xml, xsl, etc
catch (Exception e)
// this is just a test, so we'll ignore the exception
}Happy coding! :)
Doc -
Load all file names in a directory to a SQL Table
I need to load all the file names in a directory to a SQL table. It must be done via TSQL or SSIS. If using TSQL cannot use xp_cmdshell or any undocumented sprocs. So I am guessing it will be SSIS. But still open to suggestions. I am an SSIS newbie and need
a nudge in the right direction of how to get the file names into a SQL table.
ThanksLet me add a bit of background. We are sent a group of files. Each file has the ccyymmdd date attached to the name. Possible that we miss processing one day and the next day there are two sets of files in the directory. file1_20140101, file2_20140101,
file1_20140102, file2_20140102. I cannot guarantee what the file names will be. Just know that i need to process the 20140101 files in one batch, and then the 20140102 files in the next batch. So thinking that i could read all the file names into a SQL table,
distinct on the date and then sort by the date and pull off those files to process first. Thinking this will be done in SSIS. Open to any ideas or suggestions. -
How to insert the file name to the start and the end of a SQL file by a powershell script
I just began to learn powershell script and I have a problem that I cannot figure out. I have a lot of .sql files. I need to insert its file name to the beginning of the file (After USE statement) and the end of the file (before the last END statement). Is
there anybody knowing how to do this?
Thanks so much
RegardsActually, I want to add a insert SQL statement to the beginning of the file and the end of the file. Only the file name is a variable and different among
different files. All the other sql statements are the same and can be hard coded. Hopefully it helps –
The problem I think is that I want to add the same thing (except the file name) to hundreds of sql files and only the file name is different. I do not want
to add it manually and want to use a script to add it – -
How to retrieve all files in a given directory?
Hi all,
I am a newbie to Java. I have to retrieve all files in a given directory. The names of the files are not known to me. Only the name of the directory is known. How can I retrieve and read all those files?
GaryCheck out the list and listFiles method: http://java.sun.com/j2se/1.3/docs/api/java/io/File.html
-
How to open and read many files from a directory and store contents in 2D array?
I want to make a VI that opens and reads the data from various files contained in a directory (200 files each with 2 columns) and store these in a single 2D array. For file number 1 I want to store the data from both columns in the 2D array, but for files 2 to 200 I only want to store the second column of each file. Can someone please help?
Hi Nadav,
Thanks for your help. I have followed your instructions but i cannot get it to work. I used the LIST DIRECTORY to list the files in the directory - that works. However, how do I read each of the 200 files using READ FROM SPREADSHEET FILE without me having to manually select each of the 200 files? So, if I use LIST DIRECTORY to list all 200 files in an array, how do I get each of these to open and store the data in a 2D array? Here is what I have done (File called read_files.VI) Could you please help me? Thank you very much in advance.
Attachments:
read_files.vi 18 KB -
How to read the file name....
Hello all,
I have a doubt on reading file name.
I have 10 pdf files in the dir '/d01/tem/'
I need to get/load those 10 file names using PL/SQL. Meaning I need to get the file names only not the file contents...
Please help me to achieve this....
Thanks and Regards,
MuthuThere is no public synonym for DBMS_BACKUP_RESTORE, so you need to prefix it with SYS and make sure your user has execute privilege on the package. This will fix call to DBMS_BACKUP_RESTORE, but you have another issue. - fixed tables. Only SYS can read them. You'd have to login as SYSDBA, create a view around x$krbmsft and grant select on it to your user.
SQL> connect sys as sysdba
Enter password:
Connected.
SQL> grant execute on DBMS_BACKUP_RESTORE to scott;
Grant succeeded.
SQL> create view v$krbmsft as select * from x$krbmsft;
View created.
SQL> grant select on v$krbmsft to scott;
Grant succeeded.
SQL> connect scott
Enter password:
Connected.
SQL> set serveroutput on
SQL> DECLARE
2 p_directory VARCHAR2(1024) := 'C:\TEMP';
3 p_null VARCHAR2(1024);
4 i number := 1;
5 BEGIN
6 SYS.DBMS_BACKUP_RESTORE.searchFiles(p_directory, p_null);
7 FOR x IN (select fname_krbmsft fname from sys.v$krbmsft) LOOP
8 DBMS_OUTPUT.PUT_LINE(x.fname);
9 EXIT WHEN i = 3;
10 i := i + 1;
11 END LOOP;
12 END;
13 /
C:\TEMP\acbrd-0050.csv
C:\TEMP\afiedt.buf
C:\TEMP\A_3136_4000.log
PL/SQL procedure successfully completed.
SQL>SY. -
How to read a file name and send it a particular reciever
Hi,
I have a scenario, where i am receiving a a file and based on the file name i have to decide who is the receiver and send it to that particular receiver.I do not have to do any mapping.
can someone suggest me how can I achieve this.
Thanks in advance.HI This may help you.Let me know if not.
Step by Step Guide: XML File 2 XML File Scenario: Part I
Step by Step Guide: XML File 2 XML File Scenario: Part II
Converting XML to PDF using XI
Introduction to simple(File-XI-File)scenario and complete walk through for starters(Part1)
Introduction to simple (File-XI-File)scenario and complete walk through for starters(Part2)
"JAVA MAPPING", an alternate way of reading a CSV file
Dynamic File Name using XI 3.0 SP12 Part - I
Dynamic file name(XSLT Mapping with Java Enhancement) using XI 3.0 SP12 Part -II
Push Data to MVC Architectured application using XI
How to send any data (even binary) through XI, without using the Integration Repository
XI in the role of a FTP
The specified item was not found.
The specified item was not found.
The specified item was not found.
The specified item was not found. -
How to read variable file name into ODI
Hello everyone,
I apologize in advance if this has already been answered - I've done searches both on Google and this OTN area and have not found an answer to my query.
I would like to do the following via ODI:
1) rename a file in a specific directory
2) process the file
2) move the file to a backup directory
3) rename the file again
The file name is going to change everytime this process runs, as date is appended to it. I could create a variable with a system date in it and concatenate that into the filename before processing it, but I am not sure when they will run the ODI routine. Therefore, I would prefer to play it safe by doing something like a wildcard search in DOS.
Example:
Filename = TestFile12072010.csv
I would like to:
1) rename TestFile12072010.csv to TestFile.csv
2) process the file
3) move the file to another directory
4) rename the file to TestFile<processdate>.csv
I was hoping to do the first step using a DOS command that reads in TestFile*.csv. Note: I would expect there to be only 1 file with this naming convention and file extension in the directory.
I have tried creating a stored procedure that uses the Operating System type, but it runs without stopping. I have also tried ODIFileCopy and OS Command. Obviously, I am doing something wrong since I am getting errors.
Any guidance would be much appreciated! :)
Thanks!
-OSIssue was due to a syntax error. Case closed.
Thanks!
-OS -
Scripting: how to read all files in specific subfolders?
Hello,
via a Fireworks script (.jsf) I want to get all files in specific subfolders e.g. of "d:\images" to do something with these files (exporting as JPEGs).
What are these commands?
Thanks!
carlosYou would use Files.enumFiles:
http://help.adobe.com/en_US/fireworks/cs/extend/WS5b3ccc516d4fbf351e63e3d1183c94988d-7ee8. html
Aaron
http://fireworks.abeall.com -
List all file names in a directory
Hello everybody,
I need to write a script in PL/SQL (oracle 10g) that lists all filenames in a specific directory on a client machine and import the files into the database (xml files). After the file is imported they have to be removed.
I was searching for a solution for this because I have never come accross a challenge like this.
What I found was that I could use the procedure dbms_backup_restore.searchfiles of the SYS schema.
Now I need to know how this procedure works. There is very little documentation available.
Can I give the procedure a folder name on my client computer that has the xml files and let the procedure list these files?
Can someone please help me with this. I haven't got a clue.
Thanks in advance.
regards,
MarianeHello Justin,
Thank you for your reply.
You have just confirmed what I already was thinking: that the server cannot read files from the client.
I haven't got a client application running to do this. My customer wants me to write a script in PL/SQL that enables users to run an import of xml files in the database by giving in a directory name on the client.
I told my customer that they have to put the xml files on a server directory. Should that always be the server where the database resides on?
Is there another way to solve this request?
Thanks in advance.
regards,
Mariane
Maybe you are looking for
-
Price valuation with standard price in case of external procurement
Dear All, I have the following scenario with my client. All the materials will be valuated with price control S, whether procurement type is E or F. We don't have any problem if procurement type is E. But where as if procurement type is F and price c
-
Settings for Canon EOS 450, Adobe Camera RAW, PS CS 5 and printing photos
I have a Canon CS EOS 450, have used PS CS5 in the past. I have now been made aware of Camera RAW and have started using it. My problem is that the images varies when I open the photos in different programs. My laptop is a HP Probook, 64 bit, Window
-
Problem with trackpad gestures
My mac(running lion) has suddenly become non-resposive to double tap drag,resizing,minimising functions.Even in safari I cant open a new tab by simply double clicking in the tab bar.please help ...
-
i just bought an ipod, but i cnt download anthing in the app store because i do not have a credit card or any of those billing settlements.. please help me...=(
-
Certsrv not giving out UC/SAN certificates in server 2012
Hello I'm trying to use the certsrv utility to publish certificates for a fictitious set of testing domains I have. Certsrv is returning certificates, but for some reason they will not include a SAN field. I feel like the problem is that I missed a