Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: I need to get files with different timespan 1hr, 1day.1 week Date: Thu, 31 May 2018 07:47:43 -0400 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 31 May 2018 11:47:45 -0000 (UTC) Injection-Info: h2725194.stratoserver.net; posting-host="33fe12e34126543c71c0cde7edf0af02"; logging-data="3410"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rj+iX1dgoNMbv1oECfVhx" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:gQzx4rnNtMsOItSELvLx7ds18j4= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:38307 On 5/31/2018 6:07 AM, siddareddy.moolam@gmail.com wrote: > i have a folder with different files with different dates i need to get if one hour file is there or not,need to display file name > after that 1 day file need to displayed > > after 1 week file name should be displayed .. > Ex: > > 31-05-2018 folder inside filename is like these : 31-05-2018_10-42-25_rakesh_hike_load_608_output.txt if i need to enter 1 day details i need to display that file What difficulty are you having? Here are a few hints about possible solution steps: - To inspect the names of files and folders contained in another folder, start with a File object representing the container and use its list() or listFiles() method: File folder = new File("C:\\Users\\siddareddy\\folder"); for (String name : folder.list()) System.out.println(name); // ... or ... for (File child : folder.listFiles()) System.out.println(child); - To convert the first part of a file name to a time stamp (so you can easily compare it to "Yesterday" or "Last week"), first separate the date-and-time portion from the rest: String name = "31-05-2018_10-42-25_rakesh_hike_load_608_output.txt"; String prefix = "31-05-2018_10-42-25"; ... then use a SimpleDateFormat to parse the prefix: DateFormat format = new SimpleDateFormat("dd-MM-yy_HH-mm-ss"); Date stamp = format.parse(prefix); If this doesn't help you get started, please tell us more about the problems you are facing. -- esosman@comcast-dot-net.invalid Nine hundred sixty-five days to go.