Reading all files froma folder
Hi ,
Does anyone know how to read the data from all text files in a given folder?
I mean does text_io recongnises a certain sintax to do this?
Thanks,
Sandu
Well
I'm having problems initializing a java.lang.String as ora_java.jobject.
I was able to import in forms my class ,(wich works ok when tested like standalone java class,it returns all the filenames from a folder),a package was generated on the form for it.
But,I've got to pass it the folder name as a String.
I've imported java.lang.String as ora_java.jobject,and a package was generated on the form.
When I try to call string.new('c:\work');
it won't compile,it says invalid reference to variable String.
What should I do?Is there any predefined Type in ora_java package for java.lang.String?
Thanks,
Sandu
Similar Messages
-
Hello!
Here's the question with explaniation: How can i format the USB or Drive by clicking a button what's meant for it?
and the second question what's also in vb.net: How can i remove all files from folder ?
Here's the Look of program: *
Using the PC button, it will delete the free space of the PC, do you guys/girls know where it's location?Example Code:
Imports System.Runtime.InteropServices
Imports System.IO
Public Class Form1
Dim CBoxDrives As New ComboBox
WithEvents FButton As New Button
<DllImport("shell32.dll")> _
Private Shared Function SHFormatDrive(ByVal hwnd As IntPtr, ByVal drive As UInteger, _
ByVal fmtID As UInteger, ByVal options As UInteger) As ULong
End Function
Private Enum SHFormatFlags As Integer
SHFMT_ID_DEFAULT = &HFFFF
SHFMT_OPT_FULL = &H1
SHFMT_OPT_SYSONLY = &H2
SHFMT_ERROR = &HFFFFFFFF
SHFMT_CANCEL = &HFFFFFFFE
SHFMT_NOFORMAT = &HFFFFFFD
SHFD_FORMAT_FULL = 0 ' full format
SHFD_FORMAT_QUICK = 1 ' quick format
End Enum
Private Sub FButton_Click_1(sender As System.Object, e As System.EventArgs) Handles FButton.Click
If CBoxDrives.Text = "" Then
MsgBox("No Drive Selected")
Exit Sub
End If
Dim Iresult As ULong = SHFormatDrive(CType(Me.Handle.ToInt32, IntPtr), CUInt(Asc(CBoxDrives.Text.Substring(0, 1)) - Asc("A")), CUInt(SHFormatFlags.SHFMT_ID_DEFAULT), 1)
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(200, 100)
With FButton
.Size = New Size(50, 25)
.Location = New Point(5, 5)
.Text = "Format"
End With
Me.Controls.Add(FButton)
With CBoxDrives
.Size = New Size(50, 25)
.Location = New Point(75, 5)
.DropDownStyle = ComboBoxStyle.DropDown
End With
Me.Controls.Add(CBoxDrives)
Dim DrivesFound As Integer = 0
Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo
For Each d In allDrives
If ((d.DriveType = DriveType.Fixed) Or (d.DriveType = DriveType.Removable)) AndAlso Environment.GetEnvironmentVariable("SYSTEMROOT").StartsWith(d.Name) = False Then
CBoxDrives.Items.Add(d.Name)
DrivesFound += 1
End If
Next
CBoxDrives.SelectedIndex = DrivesFound - 1
End Sub
End Class -
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 contineously file from folder
HI
I have 1000 of files and I want read files from folder automatic. Each file ends with
if $BATCH_FILE==true
define $END,false
else
power off
define $END,true
if 1 text file is finish then it should load another file automaticallyHi kalu,
don't know what you're trying to do:
- you have a "path" control but you don't use it for ListFolder...
- you get an array of filenames from ListFolder, but you don't use that data later on...
- you are using "OpenFile"/CloseFile to get a file path (in the event) and later on you use that path to read data from...
Your original question doesn't has anything in common with those things you do now...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
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++; -
i need to get a file from application server folder with date validation.
how do i get the file from foder with fname, size and date.Hi,
Please try this.
DATA: FILETAB TYPE TABLE OF FILE_INFO,
FILEREC TYPE FILE_INFO,
COUNT TYPE i,
FZISE TYPE i.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = '<Yourfilename>'
FILTER = ''
FILES_ONLY = 'X'
CHANGING
FILE_TABLE = FILETAB
COUNT = COUNT
EXCEPTIONS
CNTL_ERROR = 1
DIRECTORY_LIST_FILES_FAILED = 2
WRONG_PARAMETER = 3
ERROR_NO_GUI = 4
others = 5.
IF SY-SUBRC <> 0.
RAISE CNTL_ERROR.
ENDIF.
IF COUNT = 0.
* Does not exist
RESULT = ABAP_FALSE.
FSIZE = 0.
ELSE.
* Does exist
RESULT = ABAP_TRUE.
READ FILETAB INDEX 1 INTO FILEREC.
FSIZE = FILEREC-FILELENGTH.
ENDIF.
Regards,
Ferry Lianto -
Reading All Files inside folder codeBase, Applet!
I have an applet, placed in a Jar file.. everything is ok,,
I have a resource folder outside the Jar, which has some files.
how can I read what is inside the resource folder, which is located outisde the Jar, without having their addresses before hand!!
in short, I would like the applet to open the resource folder, get an array of all files in the folder, and then reads them.
I tried encapsulating the getCodeBase().toURI() with a File Object.
But when I call the file.list() it throws an AccessControlException
thank you.Here is a simple example of using ftp to obtain file list using Jakarta common net package.
// ftp - related imports
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
// main method
FTPClient ftpClient = null;
try {
ftpClient = new FTPClient();
ftpClient.connect("REMOTE_HOST", "remote port, use 21 in common case");
System.out.print(ftpClient.getReplyString());
int reply = ftpClient.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftpClient.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
boolean isLoggedIn = ftpClient.login("your login", "your pass");
ftpClient.changeWorkingDirectory("/your remote dir/");
String[] fNames = ftpClient.listNames();
for (int i = 0; i < fNames.length; i++) {
System.out.println(fNames);
ftpClient.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(ftpClient.isConnected()) {
try {
ftpClient.disconnect();
} catch(IOException ioe) {
ioe.printStackTrace();
System.exit(0); -
ITunes doesn't adds all files from folder?
Dear Apple,
I'm having *itunes 8.1.1*,and i do like this;
file -> add folder to library (or something, it's in dutch).
And he only adds 397 files of 1030 in that folder.
How come? *Please help me!*
Tom.
Message was edited by: faceplant!faceplant! wrote:
nope, nothing happens
Well if they will not add one at a time, then adding a folder full of them will not work either. So...
Are you sure they are MP3 files? If so, see if they play in another player, such as Windows Media Player. If they play in WMP but not in iTunes, then the problem may be minor corruption in the MP3 headers, which can be cleaned up in a tool such as MP3 Valdator, as Garth mentioned.
If they will not play in either iTunes or WMP, then you can suspect that they are not valid song files. -
How to read all files from a folder Diadem
Hello,
Can somebody tell me how to load automatic some .csv file form a folder to Data Portal in Diadem.
I do some tests and during this tests I record data ( .csv files), files that I load manual now (*FileNameGet command), but I want when the tests are done and I load the script, then atomatic to load the csv files, analyze and build the report.
Please advice me how can I do that.
Thank you
(Attached you have my program)
Solved!
Go to Solution.
Attachments:
scripts.zip 10 KBDuplicate Post here:
http://forums.ni.com/ni/board/message?board.id=60&message.id=10467#M10467
David_L | Certified LabVIEW Architect
LabVIEW Tools Network | LabVIEW Tools Network Developer Center -
Reading files from folder in java
Hi ..I am new to java ..can you help me ..how to read the files from folder(containing 10 java files) and store in a array..
Thanksuse the java.io package, more specifically java.io.File. You can construct a new File by passing in a String version of the pathname, and then store that into your array.
-
FTP Adapter to read multiple files from a directory. Not through polling.
Dear Friends,
I would like to know is it possible to configure the FTP adapter in Oracle BPEL 10.1.3.4 to read multiple files (different names, same structure) from a given directory. I do not want the BPEL to do a polling. Instead when I submit the BPEL process it should read all files from the directory.
I was looking at the option of Synchronous read but I am not able to specify wild card in the file name field. I do not know the file names at the time of reading.
Thanks for your help!Hi,
While you read the file, you can configure an adapter property in 'Receive'. This will store the filename, this filename can be used for sync read as the input parameter.
1. Create a message type variable called 'fileheader'. This should be of type Inboundheader_msg (whatever relevant Receive activity).
2. This variable will contain three parts - filename, FTPhost, FTPPort
3. Copy this fileheader to 'Syncheader'.
4. syncheader can be passed as an adapter proerty during sync read of the file.
During Receive and Invoke, you need to navigate to 'Adapter' tab to choose the created message type variable.
Let me know if you have further questions.
regards,
Rev -
How to read the file from a folder.
Hi All,
How to read the file from a folder or directory from the non sap server / remote server.
Regards
Sathisopen dataset filename for input in text mode
encoding default.
filename is character type variable with the destination filename.
Edited by: Jino Augustine on Apr 19, 2010 1:31 PM -
How to read .mdb file from shared folder
Hi All,
In one of my local computer I have a shared folder and within the folder I have a .mdb file. Now I am trying to read that file from MII. I have tried with Get_File_List action block. I am providing the following information to Get_File_List
Folder :
<Computer Name>\<Shared Folder Name>
Mask: .mdb
But in return of Get_File_List, I am not getting any file related information. It is only providing like below
<Rowsets>
<Rowset>
<Columns>
<Column Description="Name" MaxRange="0" MinRange="0" Name="Name" SQLDataType="1" SourceColumn="Name"/>
<Column Description="Date" MaxRange="0" MinRange="0" Name="Date" SQLDataType="93" SourceColumn="Date"/>
<Column Description="Size" MaxRange="100" MinRange="0" Name="Size" SQLDataType="4" SourceColumn="Size"/>
<Column Description="LastWriteDate" MaxRange="0" MinRange="0" Name="LastWriteDate" SQLDataType="93" SourceColumn="LastWriteDate"/>
<Column Description="ReadOnly" MaxRange="1" MinRange="0" Name="ReadOnly" SQLDataType="4" SourceColumn="ReadOnly"/>
<Column Description="FullPath" MaxRange="0" MinRange="0" Name="FullPath" SQLDataType="1" SourceColumn="FullPath"/>
</Columns>
</Rowset>
</Rowsets>
Can anybody suggest me how to achieve it.
Thanks in advance
ChandanHi Chandan,
Specify the mask as *.mdb and try.
Thanks,
Dipankar -
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 -
How to read list of all files in folder on application server?
How to read list of all files in folder on application server?
Hi,
First get the files in application server using the following function module.
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
name = loc_fdir
TABLES
file_tbl = int_filedir.
Here loc_fdir contains the application server path.
int_filedir contains all the file names in that particular path.
Now loop at int_filedir.
OPEN DATASET int_filedir-name FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE wf_mess.
MESSAGE wf_mess.
IF sy-subrc = 0.
DO.
READ DATASET pa_sfile INTO wf_string.
IF sy-subrc <> 0.
EXIT.
endif.
close datset int_filedir-name.
endloop.
Maybe you are looking for
-
Need to e-mail job log after job completes (SM37)
Greetings! I need to export the results of the Job Log (run SM37, double-click a finished job and then click "Job Log" button at top - this is the list I need). Obviously, the program has already terminated so it won't be able to initiate it. Is th
-
HP Officejet Pro 8000 wireless and windows7 starter
I just bought a mini notebook with windows 7 starter. Can I print to my HP Officejet Pro 8000 Wireless and where can I find the drivers?
-
Compiling differently for debug and release
I want to produce slightly different .class files for my debug and release compilations. For debug, methods like toString() should return rich information which should not be present in the release version. In fact, I want most of my debug specific c
-
Hi, and first of all, sorry for my english. I've got a working tv card with node /dev/video and /dev/video0, and a webcam that should be at /dev/video1, but it's not. [samuel@arch ~]$ ls -l /dev | grep video lrwxrwxrwx 1 root root 10 mar 1
-
when my friend sends me a ichat video chat request, my cam light comes on, but my cam, nor hers, nor the request she sent shows up, nor does it make the ringing sound when a call is coming in. also it says she is in another chat but shes not. and whe