Reading few files at a time

I want to be able to read just few files at a time in a given directory. File Class provides .list() but it gets all the files or if I use FileNameFilter then based on file name - still it will try to read all the file names. But what I want is to read few files. We have 3 million files in a directory, how can I read 100 or say 1000 files at a time. File.list() is going to try to load all the file names at once.

How to do that without reading the entiredirectory?
JVM doesn't have to load the entire list to do this.
It could be implemented using native OS calls. I
don't know if they exist or not or if JVM has
bindings to them, etc. But I was hoping there was
something there. I guess not."...getting a list of files that match some search criteria?" (as you said) requires something (Java or an underlying native OS) to acquire the entire directory listing and then select from the listing, in some manner. And this is what the OP didn't want to do.

Similar Messages

  • Reading one file at a time using File Adapter

    I am using a File Adapter which polls every minute to read files from a Folder. This process picks up all the files in that folder. What I want to achieve is that the File Adapter should read one file at a time. Is it possible to force it to wait for a few seconds before reading the Next file in the Folder. Or is there a solution to what I am trying to achieve? Any help would be appreciated.

    public static char readChar() {
    int ch;
    char r = '\0';
    boolean done = false;
    while (!done) {
    try {
    ch = System.in.read();
    r = (char) ch;
    if (r == '\r') {
    System.out.println("Not a character. Please try again!");
    System.in.skip(1);
    done = false;
    } else {
    System.in.skip(2);
    done = true;
    } catch (java.io.IOException e) {
    done = true;
    return r;
    Try this as an method and then use it..
    This code will read will be in response untill you hit the return key but will take only the first character....

  • Reading two files at a time

    Hi,
    My sender system sends two files
    1.Header
    2.Item
    I need to read both the files at a time.
    If only both the files are present in the directory,i want pick the files otherwise not.
    How can i do this validation in XI??
    Thanks.
    Rushikesh

    Hi Rushikesh,
    YOu can do this in two ways,
    Either you use BPM or Shell script
    BPM:
              get the file in BPM and wait for second file,Furthur proess can be executed only if you get second file.
    Shell script:
        Write a script to get two files or conditions in script and exit
        adapter wll call after your script.
    Thanks
    Prabhakar
    Edited by: VenkataPrabhakar Teegavarapu on Oct 21, 2008 11:32 AM

  • Reading excel files in real time

    Hello,
    I would like to have a labVIEW program which permits to read several excel files, and collect all data in a single excel file.
    I know that it is possible to write a program which can read multiple files.
    But I would like to know that if its possible to read files in a real time:
    for ex. each time there is a new excel file to read, the LabVIEW program read it automatically and add its data to the final file?
    Thank you and bests regards

    As Sam notes, it is certainly possible to merge Excel Files (I've done it, myself).  An oft-repeated Best Practice for Program Development, which I didn't understand nor start following until quite recently, is "Write the Documentation First".  In this case, you want to think carefully (and specify in a Document, which tends to "clarify your thinking") a number of issues:
    Where will you look for the Excel Files to be merged?  [Hint -- it's much easier if they are all in the same Folder).
    Where will you save the Merged File?  Will it be in the same Folder as the Source Files?
    How will the Merged File be named?  This can have an interaction effect with the previous points.
    What is the structure of the Source, and of the Merged, File?  Is it "obvious" how the Merge is to take place?
    Related to #4, are there Headers?  Multiple WorkSheets?
    How do you know when it is time to Merge?  Are you checking for new files periodically?  How often?
    In some ways, these "structure" questions are trickier to design and thornier to deal with than simply reading data from two Excel Files and writing the data to a third (which I'm calling a Merge).  Note that I'm assuming that you are really dealing with Excel files (.xls, .xlsx), for which I recommend using the Report Generation Toolkit.  If you are speaking about Comma-Separated Variable (.csv) files that LabVIEW calls "Spreadsheets", the above questions are still mostly relevant, but your approach will be a little different.
    Write yourself a Document, show it to us, and if you have ideas on how to do this, give it a try and show us your code -- we'll try to provide assistance if you "get stuck".
    Bob Schor

  • Why does my quicktime player verson 10.2 somtimes read avi files and other times it wont recognize them?

      Why does my quicktime player version 10.2 sometimes read AVI video and other times it will not recognize that same file. I have a video card that sometimes it will read then the next time it recognizes the card but will not open the video. Message says "quicktime does not recognize this file.
    Whats up with that ??? Any help will be most appreciated!

    AVI is a container just like MKV, WMV, MOV, and MPEG. It is possible to use many different compression formats aka. codecs in an AVI container.
    Think of the container - AVI as being an envelope, and the compressed video in it as a letter. The letter may be in a language you cannot read even though you know how to open the envelope.
    Historically QuickTime did have some built-in ability to use AVI files and some formats in those files, this used to be further improved by installing the free Perian (for Mac only). However with Mavericks Apple have removed the ability for QuickTime X aka. QuickTime Player 10 to use AVI files, it now really only accepts MPEG4 or H.264.
    It is still possible to install QuickTime 7.6.6 in Mavericks and if you use it and Perian rather than QuickTime X you can still use various AVI files.
    Note: Mavericks also now no longer shows previews or thumbnails for AVI files for the same reason.

  • Can only copy few files at a time from DVD

    I received two DVDs from our wedding photographer and when trying to copy a DVD with about 400 images to my Mac it always fails somewhere in the process, with the drive making a disconcerting scratching noise just before it stops. Once it fails the only option is to force quit Finder and then force restart. Tried copying all the files at once from the second DVD and same result.
    I have been able to copy small batches files, a few at a time, and am up to about 100 of the 400 on disk one but it has taken hours. Sometimes it fails on a batch of 10, sometimes not, and I can always eventually copy the files in the failed batch do I don't think the files are corrupt on the DVD, nor do there appear to be any scratches. Each time it fails my only recourse is to force restart and try the batch again. At this rate it could take 20 hours to copy images from both DVDs.
    Any idea how to fix this? Here is info on my drive:
    MATSHITA DVD-R UJ-867:
    Firmware Revision: HA13
    Interconnect: ATAPI
    Burn Support: Yes (Apple Shipping Drive)
    Cache: 2048 KB
    Reads DVD: Yes
    CD-Write: -R, -RW
    DVD-Write: -R, -R DL, -RW, +R, +R DL, +RW
    Write Strategies: CD-TAO, CD-SAO, DVD-DAO
    Media: To show the available burn speeds, insert a disc and choose View > Refresh

    Thank you for the replies. After using both my laptop and another laptop to copy the files we finally got them all copied. Both laptops exhibited similar behavior on both DVDs so it probably is the type of DVDr (. The scratching was not the laser motor seeking to read the disk, rather it was relative to the spinning speed of the dvd, as if it were warped or had a piece sticking off of it, and it scratched more the faster the DVD spun, but the DVD looked to be fine. I have since tried other DVDs and they work fine so still not sure what the problem was but the files are on my HD now so that problem is solved.
    -Lewis

  • Read txt file 1 char @ time cnvrt to uppercase problem

    I am trying to get the following 2 problems solved. My input file is below and my output is below along with the code.
    Can anyone fix this and explain what I am doing wrong? Thank You in advance!
    (1) Any string of two or more blanks symbols is replaced by a single blanks.
    (2) All sentences start with an upper case letter.
    Input A://DataIn.txt = How me? you good.
    Output A://DataOut.txt = H o w m e Y U G O . ��
    import java.io.*;
    public class NumberFormat
    private DataInputStream inputStream = null;
    private DataOutputStream outputStream = null;
    *(1) Any string of two or more blanks symbols is replaced by a single blanks.
    (2) All sentences start with an upper case letter.
    public static void main(String[] args) throws java.io.IOException
    NumberFormat twoTimer = new NumberFormat();
    twoTimer.connectToInputFile();
    twoTimer.connectToOutputFile();
    twoTimer.readInput();
    twoTimer.closeFiles();
    System.out.println("Check A:/DataOut.txt Now");
    public void connectToInputFile()
    String inputFileName = getFileName("Enter input file name: A://DataIn.txt");
    try
    inputStream =
    new DataInputStream(
    new FileInputStream(inputFileName));
    catch(FileNotFoundException e)
    System.out.println("File " + inputFileName
    + " not found.");
    System.exit(0);
    public void connectToOutputFile()
    String outputFileName = getFileName("Enter output file name: A://DataOut.txt");
    try
    outputStream = new DataOutputStream(
    new FileOutputStream(outputFileName));
    catch(FileNotFoundException e)
    System.out.println("Error opening output file "
    + outputFileName);
    System.out.println(e.getMessage());
    System.exit(0);
    private String getFileName(String prompt)
    String fileName = null;
    System.out.println(prompt);
    fileName = SavitchIn.readLineWord();
    return fileName;
    //===========================================================================
    public void readInput()
    char prevChar = ' ';
    try
    char nextChar;
    String result = "";
    boolean done1 = false;
    boolean done2 = false;
    char next;
    do
    next = (char) (inputStream.read()); // <== Read input 1 Character @ time
    if (next == '\n')
    done1 = true;
    if (next == ' ' && next == prevChar)
    prevChar = next;
    else
    if (next == '.' || next == '!' || next == '?')// <== Capitalize next input Character
    do
    next = ' ';
    outputStream.writeChar(next);
    next = (char) (inputStream.read());
    if (next == '\n')
    done2 = true;
    next = (char) (inputStream.read());
    // next = (char) (inputStream.readNonwhiteChar()); ?????????????
    if (next == '\n')// <== never gets to end of file
    done2 = true;
    outputStream.writeChar(Character.toUpperCase (next));
    prevChar = next;
    while (!done2);
    else
    outputStream.writeChar(next);
    prevChar = next;
    while (!done1);
    catch(EOFException e)
    //Do nothing. This just ends the loop.
    System.out.println("Do Nothing Here");
    catch(IOException e)
    System.out.println(
    "Error: reading or writing files.");
    System.out.println(e.getMessage());
    System.exit(0);
    public void closeFiles()
    try
    inputStream.close();
    outputStream.close();
    catch(IOException e)
    System.out.println("Error closing files "
    + e.getMessage());
    System.exit(0);

    This line looks fishy:
    if (next == ' ' && next == prevChar)
    prevChar = next;Try:
    if (next == ' ' && next == prevChar)
    next = "";That should take care of the extra blanks, though I didn't test it myself, and could very well be wrong.
    Not sure about the uppercase, though I imagine it must be reading the ToUpperCase every time after the first period.

  • Reading log file and calculating time between

    If someone could help me with this one, I would be very grateful.
    I have a log file and I need to search a string that contains a start time and end time (eg. <time="11:10:58.000+000">). When I have these two values, I need to measure the time that has been elapsed between these two (from start to end).

    $Path="C:\Times.log"
    remove-item $Path
    Add-Content $Path '<time="11:10:58.000+000">'
    Add-Content $Path '<time="12:10:58.000+000">'
    Add-Content $Path '<time="13:10:58.000+000">'
    Add-Content $Path '<time="15:13:38.000+000">'
    Add-Content $Path '<time="16:10:58.000+000">'
    Add-Content $Path '<time="17:08:28.000+000">'
    $File=Get-Content $Path
    $StartTime=$Null
    $EndTime=$Null
    $ElapsedTime = $Null
    ForEach ($Line in $File)
    If ($Line.Contains("time="))
    $Position = $Line.IndexOf("time=")
    $TimeStr =$Line.SubString($Position+6,8)
    IF ($StartTime -EQ $Null)
    $StartTime = $TimeStr -As [System.TimeSpan]
    Else
    $EndTime = $TimeStr -As [System.TimeSpan]
    $ElapsedTime = $EndTime.Subtract($StartTime)
    "StartTime=$StartTime EndTime=$EndTime ElapsedTime=$ElapsedTime"
    $StartTime = $Null
    Gives this output
    StartTime=11:10:58 EndTime=12:10:58 ElapsedTime=01:00:00
    StartTime=13:10:58 EndTime=15:13:38 ElapsedTime=02:02:40
    StartTime=16:10:58 EndTime=17:08:28 ElapsedTime=00:57:30

  • CSV file reading using UTL_FILE at run time

    Hi,
    I have to read CSV file using UTL_FILE.
    but Folder contains Many CSV files.
    I dont know there name.So i have to read csv file at run time.
    Please let me know how should we achieve this?
    Thanks

    place the following in a shell script, say "list_my_files.ksh"
    ls -l > my_file_list.datthen run the shell script using dbms_scheduler;
    begin
    dbms_scheduler.create_program (program_name   => 'a_test_proc'
                                  ,program_type   => 'EXECUTABLE'
                                  ,program_action => '/home/bluefrog/list_my_files.ksh'
                                  ,number_of_arguments => 0
                                  ,enabled => true);
    end;
    /then open "my_file_list.dat" using UTL_FILE, read all file names and choose the one you require.
    P;

  • Design for reading mutiple files

    hi , my problem statement is i have to read multiple files at same time and send the content to a C++ system using socket connections. only solutions i am able to think is using executor and other classes from java concurrent api. is there any other options like using session beans or jms for solving the problem. because in future we will be changing C++ system to java

    hi , my problem statement is i have to read multiple files at same time and send the content to a C++ system Make a class called TaskFileReader which implements Future; this class is specializing in reading a file.
    submitt your TaskFileReader into an executor by looping through the file set ( different files) and add all the future into a collection
    Now you will get notified once the task is being process ( if you do not want to add the futures into the collection and loop through them after submitting them to the executor) so that you can get a call back ( look at Future documentation)
    In your call back you open a session ( socket ) with the C++ server and make your conversation of the returned data with a seperate thread or you can
    try to get the future result in the conversation thread which will block until the result is back and then you can proceed
    Regards,
    Alan Mehio
    London,UK

  • Trying to use a new, larger external hard drive for my Time Machine backup.  However, every time I start the backup, it gets started then fails.  And, I can't delete the few files that did save on the external.  Sort of a catch 22.  Any ideas?

    Trying to use a new, larger external hard drive for my Time Machine backup.  However, every time I start the backup, it gets started then fails.  And, I can't delete the few files that did save on the external.  Sort of a catch 22.  Any ideas?

    Is it a USB hard drive?  USB hard drives have the problem of not giving full speed if they are hooked up on the same bus as keyboards and mice.  Double check your profiler to make sure that is not a problem.  If it is Firewire, make sure there aren't other firewire devices in use at the same time.  I recommend not only keeping a Time Machine backup, but also a clone, and if you do use Time Machine, to make sure the Time Machine drive or partition is at least twice the size of the original drive.

  • My Time machine has stopped backing up saying there are some read only files.

    My Time machine has stopped backing up and says that ther are some read only files preventing this. What steps do I need to take to fix it?

    If you have more than one user account, these instructions must be carried out as an administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left.
    Enter the word "Starting" (without the quotes) in the String Matching text field. You should now see log messages with the words "Starting * backup," where * represents any of the words "automatic," "manual," or "standard." Note the timestamp of the last such message. Clear the text field and scroll back in the log to that time. Post the messages timestamped from then until the end of the backup, or the end of the log if that's not clear.
    Post the log text, please, not a screenshot. If there are runs of repeated messages, post only one example of each. Don't post many repetitions of the same message.
    When posting a log extract, be selective. Don't post more than is requested.
    Please do not indiscriminately dump thousands of lines from the log into a message.
    Some personal information, such as the names of your files, may be included — edit that out, too, but don’t remove the context.

  • How to read several text files at a time

    Dear all
          Read and write one text file is not a problem, but  what confusies me is how to read several text files at one time, in the meanwhile,
    is it possible to display the name of the text file?
    For example, assuming I want to load file" cha 1, cha 2 , cha 3, " at one time and show their names, how to hadle with it
    I have reviewed some files and it is not helpful

    Either with a 'for' loop like in the lib you have attached, or like this attached VI
    that's it
    Message Edited by devchander on 05-30-2006 05:11 AM
    Attachments:
    MULTIPLE READ.vi ‏44 KB

  • Read a file at a fixed time of day using PS in OSB

    I have a proxy service which read a file, now I want to read that file at a fixed time in a day(suppose 12pm every day).
    How do I make the JCA file/proxy configuration?
    Pls suggest!

    Re: How to implement in OSB: Scheduling, Timers and Custom properties
    Regards,
    Anuj

  • Read one word at a time from a text file

    I want to read one word at a time from a text file as it is done by "scanf &s" function in text based programme. It is not possible by " read from text"  function. Suggest me  function or method to solve this.

    The simplest way is to use the spreadsheet string to array function with the space character as the delimiter.
    Note that this won't work unless there is a space character between the words - it won't work with line feeds / carriage returns between the words but you could always split the string into lines first. You may also want to trim whitespace to remove any other non-visible characters (e.g. tab, line feeds) from around the word.
    If you need something more sophisticated that splits based on whitespace (e.g. tab, new line) then you'll probably need to do something with searching the string for these characters (e.g. using a regular expression) and then splitting them yourself into an array.
    Of course...if you actually want to just read one word at a time from the file rather than just split the file into words (I assumed you meant this), you will need to read the file byte by byte using the low level file IO functions, build a buffer of the bytes and check the character you've read to see if it a space.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

Maybe you are looking for

  • How do I create an anamorphic viewer with QT7 Pro?

    I have video that is anamorphic (16:9). I can't figure out how to create a viewer size that will show the movie without having to letterbox it. Is there an anamorphic selection in Quicktime 7 Pro that I am missing? I am using the H.264 codec. Thanks

  • Two Apple TVs not showing photos in Fotostream

    Hello I had to reset both my Apple TVs (newest gen) due to Wifi issues and reconfigured everything. FW is the newest 5.3.. Since then, Fotostream does not show the pictures I have in my fotostream. Instead the error reading is "0 fotos, no fotos in a

  • BEx : several gl accounts in the rows

    Hi Experts, I need to display a few GL accounts in the rows and the respective 0balance in the columns but does not want to use hierarchy nodes for these. Any clue how this can be created? Regards M Russo

  • TS1702 Phone stuck on the updating screen. Black with the apple and loading bar.

    Updated to iPhone ios6. It started uploading the software. Iphone screen black with the apple and the loading bar. It's stuck there. Won't do anything. Itunes doesnt even recognize it anymore.

  • XSL support level

    I have a form that will need to be transformed on the way in and on the way out. I am using MapForce to create the mappings between the two. It appears that some of the functions I need are XSLT 2.0 exclusive. Does LiveCycle support XSLT 2.0?