How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap?

How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would like to cache this data in order to use it later. How can I do this using the TreeMap Class? These are the keys,values: TreeMap The data I'd like to Cache is (date from the file, time of the file, current time).
import java.io.*;
public class CacheData {
  public static void main(String[] args) throws IOException {
  String target_dir = "C:\\Files";
  String output = "C:\\Files\output.txt";
  File dir = new File(target_dir);
  File[] files = dir.listFiles();
  // open the Printwriter before your loop
  PrintWriter outputStream = new PrintWriter(output);
  for (File textfiles : files) {
  if (textfiles.isFile() && textfiles.getName().endsWith(".txt")) {
  BufferedReader inputStream = null;
  // close the outputstream after the loop
  outputStream.close();
  try {
  inputStream = new BufferedReader(new FileReader(textfiles));
  String line;
  while ((line = inputStream.readLine()) != null) {
  System.out.println(line);
  // Write Content
  outputStream.println(line);
  } finally {
  if (inputStream != null) {
  inputStream.close();

How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would like to cache this data in order to use it later. How can I do this using the TreeMap Class?
I don't understand your question.
If you don't know how to use TreeMap why do you think a TreeMap is the correct solution for what you want to do?
If you are just asking how to use TreeMap then there are PLENTY of tutorials on the internet and the Java API provides the methods that area available.
TreeMap (Java Platform SE 7 )
Are you sure you want a map and not a tree instead?
https://docs.oracle.com/javase/tutorial/uiswing/components/tree.html

Similar Messages

  • How can I view The date, time, sender and/or receiver of a text message online?

    I would like to view the date and time sender and receiver of my text messages I read it can be done. I can't find where. If somone one could point me out in the right direction I would appreciate it. Thanks

    Log into your account and to the right of the phone photo you will see usage details in blue then on the next screen pick the phone on the account you want to see the details for and under that you can click to see eveyrthing in detail.  Mary

  • How can we give the Data Format (File Type ) in Runtime

    Hi all,
    How can we give the Data Format (File Type ) in Runtime for the following method,
    cl_gui_frontend_services=>gui_download.
    Thanks in advance
    Sri

    There is a filetype parameter which you can set
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
    *    BIN_FILESIZE              =
        filename                  =
    *    FILETYPE                  = 'ASC'
    *    APPEND                    = SPACE
    *    WRITE_FIELD_SEPARATOR     = SPACE
    *    HEADER                    = '00'
    *    TRUNC_TRAILING_BLANKS     = SPACE
    *    WRITE_LF                  = 'X'
    *    COL_SELECT                = SPACE
    *    COL_SELECT_MASK           = SPACE
    *    DAT_MODE                  = SPACE
    *    CONFIRM_OVERWRITE         = SPACE
    *    NO_AUTH_CHECK             = SPACE
    *    CODEPAGE                  = SPACE
    *    IGNORE_CERR               = ABAP_TRUE
    *    REPLACEMENT               = '#'
    *    WRITE_BOM                 = SPACE
    *    TRUNC_TRAILING_BLANKS_EOL = 'X'
    *  IMPORTING
    *    FILELENGTH                =
      changing
        data_tab                  =
    *  EXCEPTIONS
    *    FILE_WRITE_ERROR          = 1
    *    NO_BATCH                  = 2
    *    GUI_REFUSE_FILETRANSFER   = 3
    *    INVALID_TYPE              = 4
    *    NO_AUTHORITY              = 5
    *    UNKNOWN_ERROR             = 6
    *    HEADER_NOT_ALLOWED        = 7
    *    SEPARATOR_NOT_ALLOWED     = 8
    *    FILESIZE_NOT_ALLOWED      = 9
    *    HEADER_TOO_LONG           = 10
    *    DP_ERROR_CREATE           = 11
    *    DP_ERROR_SEND             = 12
    *    DP_ERROR_WRITE            = 13
    *    UNKNOWN_DP_ERROR          = 14
    *    ACCESS_DENIED             = 15
    *    DP_OUT_OF_MEMORY          = 16
    *    DISK_FULL                 = 17
    *    DP_TIMEOUT                = 18
    *    FILE_NOT_FOUND            = 19
    *    DATAPROVIDER_EXCEPTION    = 20
    *    CONTROL_FLUSH_ERROR       = 21
    *    NOT_SUPPORTED_BY_GUI      = 22
    *    ERROR_NO_GUI              = 23
    *    others                    = 24

  • HOW CAN U CORRECT THE DATA IN UR FILE WHICH CONTAINS 1 LAKSH RECS

    Hai Frnds,
    i Attend an interview they asked this questions can u know the answeres . tell me .
    In File to file scenario how can we reprocess records which failed records.
    HOW CAN U CORRECT THE DATA IN UR FILE WHICH CONTAINS 1 LAKSH RECS
    Thanks in advance
    thahir

    Hi,
    Refer these links:
    this might help you
    Generic Approach for Validating Incoming Flat File in SAP XI - Part 1
    Generic Approach for Validating Incoming Flat File in SAP XI - Part 1
    validating against schema file for the output XML file
    Informing the sender about bad records
    Regards,
    Nithiyanandam

  • How can we view the data asociated with Request ID

    Hi All,
    I have data loaded in an ODS there are multiple files loaded in this ODS. Now i want to view data for a perticuler request OR i want to know how can we know the data associated with a perticular request.
    Please help me out.
    Thanks & Regards
    Amit Kumar

    Copy the request number (not request ID) from the ODS manage screen, Goto RSRQ give the request number and execute. it shows the monitor screen- now goto PSA from the top and check the data. But this possible only if you are loading data to PSA also along with ODS.
    Otherwise, Goto Display Data of ODS from the right click on it -- in the selection screen give the Request ID that you want to check the data. Then it displays only that request data.
    Hope this helps.
    Veerendra.
    Edited by: denduluri veerendra kumar on Dec 1, 2009 12:40 PM
    Edited by: denduluri veerendra kumar on Dec 1, 2009 12:43 PM

  • How can I display the data in table in separate column?

    I have a vi reading data one by one in the same column.
    How can I display the data with separate column?
    like this:
    data 1 | read | read
    data 2 | read | read
    data 3 | read | read
    (would you mind if I will ask for an example
    because it is much easier for me to work
    with an example)
    THANK YOU.

    If you're reading your data in as a 1D array, this is as simple as using the Reshape Array to make a 2D array. I've attached an example in LabVIEW 6.1 format. The example rearranges a single column of data fill several columns horizontally, but you can easily modify this code to fill the columns downward instead.
    Attachments:
    Data_Column_Example.vi ‏18 KB

  • My parents have one apple id and me and my two other siblings are getting our own. How can I transfer the data saved on the parent apple id to all three kids apple ids?

    Me and my siblings all want our own apple ids, and my mom has the apple id that has all of our games, apps, movies, and music on there. how can we copy the data onone apple id to the three kid accounts?
    thanks!

    Sorry, but unless I misunderstand what you're asking, you can't. Purchases from the iTunes Store are permanently tied to the Apple ID through which they were purchased. If your parents want you to be completely independent of their Apple ID and iTunes Store account, you'll each have to re-purchase the apps, etc. Otherwise they'll have to continue to allow you access to their account, or will have to do all the updates for you.
    Regards.

  • How Can we get the data from Non-SAP to SAP in WebDynpro

    Hi,
    I hope u understand my query, How can we get the data from Non-SAP to SAP thru WebDynpro Programming.
    Help out with the steps for getting the data or procedure.
    Regards,
    Mutyapu

    You can expose the APIs in the Non-SAP backend as Web Services, and consume them in SAP by creating an Enterprise Proxy. Then these can be called just like normal class methods from Web Dynpro.
    Regards,
    Nithya

  • How can we delete the data in e-fact table.

    how can we delete the data in e-fact table.

    hii,
    You cannot delete the request individually but you can one of the following:
    1. Do a selective deletion from the cube. RSA1 -> Cube -> Contents -> selective deletion.
    2. Delete all the data in the cube and then reconstruct only the required request ids. This would work only if you have the PSA available for all the requests.
    3. Reverse posting is another possibility.
    hope it helps,
    partha

  • How can we acess the data of one component into othr component in webdynpo?

    How can we acess the data of one component into other component in webdynpro....
    I need an Field input from one webdynpro component(comp1)  which is away from the line of process to the other component(comp2) we need that data........I mean i need the field info of comp1 where we doesn't navigate through the Comp1 in the portal & directly access the  component comp2.........kindly share your ideas.....and possible ways .........
    any doughts do post.....
    thanks in advance!

    Hi,
    Please post your query in forum Web Dynpro ABAP Forum, under Application server.
    You have to define the source component as in the used component in the target one to do that.
    after that you will be able to get data from that component.
    Regards,
    Vaibhav

  • How can we acess the data of one component into othr compnent in webdynpro?

    How can we acess the data of one component into other component in webdynpro....
    I need an Field input from one webdynpro component(comp1) which is away from the line of process to the other component(comp2) we need that data........I mean i need the field info of comp1 where we doesn't navigate through the Comp1 in the portal & directly access the component comp2.........kindly share your ideas.....and possible ways .........
    any doughts do post.....
    thanks in advance!

    Hi Reddy,
    You can do it in multiple ways. One way would be to try transfer the parameters through URL & the other would be to work with the concept of interface nodes. Please try go through these 2 threads ( [Thread 1|Call view of another WDA Component and pass the value to it; & [Thread 2|navigation from one program to another; )where I have explained about working with Interface node in detail. You can refer to this [thread |receving parameters between two standard webdynpro applications;to see as to how you can do the same via parameters in URL.  Hope it would help resolve your problem.
    Regards,
    Uday

  • How can i change the date of birth on my account

    how can i change the date of birth on my account

    Hello! Please login here: https://appleid.apple.com/account/manage
    Then go to "Password and security"
    Answer your security questions and the birthdate option will appear.

  • How can i save the data in a jpanel form to a .txt document

    how can i save the data in a jpanel form to a text file using parse function,this should happen when i click a save button .
    please help me..

    each time when i fill the form and click save button ,all the data in the form should be written to a text file and each time when i repeat it should append to the old data in the text file.the elements in the form should be seperated by pipe delimeter.
    thanks for your patience..

  • HT201269 how can I transfer the data of my old iphone to the new one?

    I have skipped the setup part of the new iphone, how can I transfer the data of my old iphone to the new one?

    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device - http://support.apple.com/kb/HT2109

  • How can i view the data from Access DB in oracle

    pls tell me that how can i view the data of MS ACCESS DATABASE in ORACLE.i was use ODBC of ACCESS DATABASE AND THEN CREATE DATABASE LINK IN ORACLE BUT NOT YET SUCCEEDED.PLS TELL ME THE PROCEDURE.
    regard's

    hi,
    u nedd to use Oracle Hetrogeneous Services,,
    full details of the procedure u may fing on metalink
    Regards

Maybe you are looking for

  • Pf status in alv

    Hi all, I have to add a button to alv list display output to proceed further ( along with other standard buttons like select all/ filer/ sorting etc). can anybody help me please. thanks, sudheer

  • My ipod photo can not be read from or written to?

    My ipod photo flashes up with the following message when conected to the Mac and iTunes : "Attempting to copy to the disk "Ste's iPod" failed. The disk could not be read from or written to." Does this mean the disc in broken and it needs sending back

  • Best practice with respect to wcf configuration files for SSIS

    So after reading a lot of posts and blogs on how to configure SSIS to read from configuration files , I am still not clear and would like any expert to provide a definitive stance. In my case the WCF service consumption is wrapped into a separate ass

  • What are these weird things in Apple Mail?

    Hi, Does anyone know what these weird things are in Apple Mail? (Please ignore the yellow markers) It often happens when I open the application in the first e-mail. Thanks! Teun

  • Gateway unexpectedly closed the connection..

    When I try to Test Connection for the Active Directory Resources it shows the following error The gateway unexpectedly closed the connection with an exception, check the gateway trace for more information. ==> java.net.SocketException: Connection res