Need to read all files in a foldert to a list BUT HOW !
Hi guys
Thanks for all the help I have been getting here. I just wish I could help someone else, but that day will come. Well I hope so.
I would like to know the best way (no the easiest way) of reading the entire file in a folder into a list.
Can someone point me or show me how this is done?
I possible to show me a snippet of code to get me started would be great
Thanks
Craig
Here is some untested code:
import java.io.File;
import java.util.Arrays;
import java.util.List;
File dir = new File("C:/winnt");
File[] files = dir.listFiles();
// You wanted it in a list. I guess you just mean a java.util.List.
List fileList = Arrays.asList(files);Jesper
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 -
Reading all files on directory using "utl_file" package...
I need to read all files in directory via PL/SQL. I don't know
name files (are data dynamics create for automation system),
only I know your extensions.
Can I do this using the package "utl_file" or I need to create
program in another language (C, C++, for example)?
Any ideas...
Thanks.Hi,
you can't do that with the UTL_FILE package (it can't retrieve
file names).
A very simple solution would be, if you created on OS-level a
file which contains the filenames of directory and then read this
file using UTL_FILE. With the information on all file names you
can enter a loop which opens and reads all files again using
UTL_FILE.
A more mundane solution could be to use the features on the iFS.
Cheers
Gerald -
Need to read all entris for field prtxt from table /sapsll/prt
hi
i need to read all entries from table /sapsll/prt field prtxt but only one is coming
pls see below seelct statement
if not gt_sagmeld[] is initial.
SELECT /sapsll/cuit~guid_cuit " PK
/sapsll/cuit~QUANT_FLT " to be displayed
/sapsll/cuit~QUAUM " to be displayed
/sapsll/cuit~RPTDT " to be displayed
/sapsll/cuit~guid_cuhd
/sapsll/cuit~guid_pr " needed for gt_prt inttab
/sapsll/corref~refno
/sapsll/corref~guid_pobj
INTO corresponding fields of table gt_sapsllcuit
FROM ( ( /sapsll/cuit
inner join /sapsll/cuhd on /sapsll/cuit~guid_cuhd = /sapsll/cuhd~guid_cuhd )
inner join /sapsll/corref on /sapsll/corref~guid_pobj = /sapsll/cuhd~guid_cuhd )
FOR all entries in gt_sagmeld
WHERE /sapsll/cuit~guid_cuit = gt_sagmeld-guid_pobj.
endif.
if not gt_sapsllcuit[] is initial.
select /sapsll/prt~prtxt
/sapsll/prt~guid_pr
into corresponding fields of table gt_prt
from /sapsll/prt
for all entries in gt_sapsllcuit
where /sapsll/prt~guid_pr = gt_sapsllcuit-guid_pr.
loop at gt_sagmeld into wa_sagmeld.
read table gt_sapsllcuit into wa_sapsllcuit
with key guid_cuit = wa_sagmeld-guid_pobj
binary search.
Read table gt_prcon into wa_prcon with key
guid_pr = wa_sapsllcuit-guid_pr.
if sy-subrc = 0.
*wa_sagmeld_outtab-guid_pr = wa_prt-guid_pr.
here i am facing problem as multiple entries from table /sapsll/prt is not being displayed only one.....but i have checked in table it is having two enteries
pls suggest
reagards
NishantHi Nishant!
When you use 'for all entries' SAP (or database?) does a 'delete adjacent duplicates' on the result. This is necessary because of the special selection technique in this case.
You need to select enough columns from /sapsll/prt, so that your two entries will differ in the result.
Regards,
Christian -
Hard drive failing on Macbook 13" OS 10.7.3 Need to xfer all files to an iMAC 21.5. How to do this?
Can you boot the MacBook into FireWire Target Disk mode? That turns it (temporarily) into an expensive hard drive. You can then move files.
Another way would be to use an external hard drive, attach it to the MacBook and user software such as Bombich's Carbon Copy Cloner to copy the hard drive (assuming you have sufficient space on the iMac.)
Best of luck. Please keep your data backed up in the future to avoid this. It'll make your life easier. -
Reading all files in directory
Hi
I need to read all the files inside a directory where my app resides. I have the following:
File file = new File(args[0]);
Reader reader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(reader);
This works fine for one file, but i have many files I would like to
read in this directory. I was hoping I could just do:
java MyApp *
but it doesn't work. thanks in advance for any help.
J.rtfm
http://java.sun.com/products/jdk/1.1/docs/api/java.io.File.html#list() -
Need to read text file content and have to display it in multiline text box
dear all,
Need to read text file content and have to display it in multiline text box.
actually im new to file handling. i have tried up to get_line and put_line.
in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
TEXT_IO.GET_LINE (in_file,linebuf);
i dont know how to assign this get_line function to text item
pls help me in this regards,Simply write:
in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
TEXT_IO.GET_LINE (in_file,linebuf);
:block2.t1 := chr(10)||:block2.t1||chr(10)||linebuf;
chr(10) --> is for new line character -
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 -
HT4972 do I need to copy all files on my iphone to update from 4.3.3 to 6.3
do I need to copy all files on my iphone to update from 4.3.3 to 6.3
Read the instructions in the article from which the statement was posted.
-
I am getting a message that sys startup disk is almost full. I cleaned all my old emails out, archived old ones i needed and erased most files on the computer. I restarted but I'm still getting the message
Reindex Spotlight again.
http://support.apple.com/en-us/HT201716
Do not concern yourself about the backups. They will be deleted automatically if space is needed for other data:
http://support.apple.com/en-us/HT202301
Ciao. -
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 -
I need to read Pages files but I can't install Pages on osx 10.6
I need to read Pages files, but I can't install Pages because I have OSX 10.6. Is there some version that will work?
You can get iWork 09 on the net. You haven't had Pages before? Who is sending you Pages documents? Ask them to export the document to Word or Rtf and you will be able to read the documents in TextEdit, which you have on your computer
-
Read all Files from a Folder on Server
Hi,
Can anyone help me in finding if there's any way to read all files in a folder on the server?Any Function module or anything.
ThanksOn App server? Try this sample program.
report zrich_0001 .
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
data: wa(1000) type c.
data: p_file type localfile.
data: ifile type table of salfldir with header line.
parameters: p_path type salfile-longname
default '/usr/sap/TST/DVEBMGS01/data/'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_path
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
loop at ifile.
format hotspot on.
write:/ ifile-name.
hide ifile-name.
format hotspot off.
endloop.
at line-selection.
concatenate p_path ifile-name into p_file.
clear itab. refresh itab.
open dataset p_file for input in text mode.
if sy-subrc = 0.
do.
read dataset p_file into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset p_file.
loop at itab.
write:/ itab.
endloop.
Regards,
Rich Heilman -
Read All files in folder and sub folder
Hi,
i can read files in a folder,but not in a sub folders.can any one give me idea to read all files in the folder and its sub folder.
DeepanHi
This code may help you
Bliz
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
public class CountFiles {
* @param args
* @throws IOException
* Count files in <path> and all its subDirs
public static String path = "c:";
public static String src1 = "";
public static FileChannel channel;
public static int numF;
public static int numD;
public static void main(String[] args) throws IOException {
countFiles(path);
System.out.println("Number of files :\t"+numF);
System.out.println("Number of dirs :\t"+numD);
public static void countFiles(String strPath) throws IOException
File src = new File(strPath);
if (src.isDirectory())
numD++;
String list[] = src.list();
try {
for (int i = 0; i < list.length; i++)
src1 = src.getAbsolutePath() + "\\" + list;
File file = new File(src1);
try {
channel = new RandomAccessFile(file, "r").getChannel();
}catch(java.io.FileNotFoundException e){}
countFiles(src1);
}catch(java.lang.NullPointerException e){}
else
numF++; -
Read all files in a subdirectory
I have a directoy that contains other directories which I need to read the files found in these subdirectories. I'm using the following method to read the files in a directory:class ListAll
public static void main( String args[] ) throws IOException
File currentDirectory = new File( "." );
String[] listing = currentDirectory.list();
for ( int k = 0; k < listing.length; k++ )
System.out.println( listing[k] );
}Can any one help? thanks in advance... TomDo you mean like this?import java.io.*;
class ListAll {
private void listDirectory(String dir) {
File currentDirectory = new File(dir);
String[] listing = currentDirectory.list();
for ( int k = 0; k < listing.length; k++ ) {
if (new File(dir+File.separator+listing[k]).isDirectory()) {
listDirectory(dir+File.separator+listing[k]);
System.out.println( dir+File.separator+listing[k] );
public static void main(String args[]) throws IOException {
new ListAll().listDirectory(".");
}Mark
Maybe you are looking for
-
Qosmio G10-133: I am having random lockups - Graphic driver issue
Hi my machine screen goes blank at random and i get the below error message which suggests i need finally the latest graphic driver. Uninstall the Nividea driver from my machine which appeared to fix the problem but my graphics were reduced. I then r
-
HELP: Premiere Pro CC not using all CPU and RAM during rendering and export
Hello, I am using Premiere Pro CC on a Windows 7. My timeline is quite simple with two videos, one with the movie (mpeg) and the other with the subtitles (avi). When I render the sequence in PP or export, the rendering time is way too slow and it onl
-
Dear... On EP screen I want to execute the executable file(ex: Microsoft Word, SapGui, etc) by clicking button. Is this possible? If I can execute the executable file by clicking button, please give me how to do this. thanks, sangyuun.
-
How to open mini bridge in photoshop
I am trying to figure out how to open the mini bridge panel in photoshop
-
Mac Mail migrating data freezes computer
I just installing Lion 10.7.5 from Snow Leopard 10.6.8 all fine except when I click on MAIL it freezes the whole computer (ie: can only move the mouse nothing else) and the screen says: "migrating data..." + a small amount of blue on the progress ba