Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38326

Re: I need to get files with different timespan 1hr, 1day.1 week

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: I need to get files with different timespan 1hr, 1day.1 week
Date 2018-06-01 07:43 -0400
Organization A noiseless patient Spider
Message-ID <perbht$q3n$1@dont-email.me> (permalink)
References <a8a31edc-333e-48fd-a7e0-34f38c9e0d5d@googlegroups.com> <peond1$3ai$1@dont-email.me> <6ba6236b-78bd-4224-a7be-a0dcb28e1a9a@googlegroups.com> <peovkh$r6f$1@dont-email.me> <b983ee39-50f0-4501-a9bf-c4fcf0703693@googlegroups.com>

Show all headers | View raw


On 6/1/2018 1:08 AM, msr2858@gmail.com wrote:
> 
> Problem:
> iam able to get one day files but i didnt get one hour and one week files could you please help me

     It might help if you explained exactly what "one hour files" and
"one week files" are.  Hint, hint.

> package hellomongo;
> 
> import java.io.File;
> import java.text.SimpleDateFormat;
> import java.util.Date;
> 
> public class FDate {
> 	String stringToday1;
> 	String path;
> 	String base="/home/msr/hike/";	
> 
> 	public void getdayfilnames() {
> 		Date today1 = new Date();
>          System.out.println("today1 :: " + today1);
> 	   // let us convert different formats of today1 into strings
>      	SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
>      	stringToday1 = sdf1.format(today1);
>          System.out.println("today1 :: " + stringToday1);
> 		
> 		path=base+stringToday1;
> 		System.out.println("dayysss:"+ path);

     I observe that this statement could not possibly produce the
output you claim (below).  I therefore conclude that your report
of "Here's what I did and here's what happened" is incorrect.

> 		File folder = new File(path);
> 		File[] listOfFiles = folder.listFiles();
> 		
> 		
> 		    for (int i = 0; i < listOfFiles.length; i++) {
> 		    	if (listOfFiles[i].isFile()) {
> 		    		 String fname=listOfFiles[i].getName();
> 		    		
> 		    		
> 		    		
> 		    		System.out.print("  "+fname+"  ");

     Same remark: This statement could not possibly have produced the
output you reported.  You are lying to us -- perhaps innocently, but
you are lying nonetheless.

> 		    	}
> 		    	
> 		
> 		      /*if (listOfFiles[i].isFile()) {
> 		    	  String fname=listOfFiles[i].getName();
> 		    	  System.out.println(" fname :"+fname);
> 		    	  String dayfile=fname.substring(1, 10);
> 		    	  if(day==dayfile) {
> 		    		  System.out.println(fname);
> 		    	  }
> 		      } */
> 		    }
> 
> 		
> 	}
> }


> package hellomongo;
> 
> import java.io.File;
> import java.io.FilenameFilter;
> import java.text.DateFormat;
> import java.text.ParseException;
> import java.text.SimpleDateFormat;
> import java.util.Date;
> 
> public class Timedate {
> 
> 	public static void main(String[] args)
> 	{
> 		
> 	Timedate td=new Timedate();

     Why bother with this?  It burns a few CPU cycles, chews
up a little bit of memory, and accomplishes nothing useful.

> 	FDate fd=new FDate();
> 	fd.getdayfilnames();
> 	
> 	  }
> 	}

> Output for oneday files:

     ... except this is not the actual output, not from the code
you've shown at any rate.

> dayysss:/home/msr/hike/31-05-2018:
> 31-05-2018_10-42-25_rakesh_hike_load_608_output.txt
> 31-05-2018_10-42-38_rakesh_hike_cpu_bd7_output.txt
> 31-05-2018_10-42-46_rakesh_hike_ram_d8c_output.txt

     Others may (or may not) be more patient with you, but I for
one will offer no further help until:

     1) You define *precisely* what is meant by "one day files",
"one hour files" and "one week files,"

     2) You explain in more detail where the various files reside
and in what folders,

     3) You exhibit code and output (or error messages) that *match*.

-- 
esosman@comcast-dot-net.invalid
Nine hundred sixty-four days to go.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I need to get files with different timespan 1hr, 1day.1 week siddareddy.moolam@gmail.com - 2018-05-31 03:07 -0700
  Re: I need to get files with different timespan 1hr, 1day.1 week Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-05-31 07:47 -0400
    Re: I need to get files with different timespan 1hr, 1day.1 week siddareddy.moolam@gmail.com - 2018-05-31 05:59 -0700
      Re: I need to get files with different timespan 1hr, 1day.1 week Eric Douglas <e.d.programmer@gmail.com> - 2018-05-31 06:52 -0700
      Re: I need to get files with different timespan 1hr, 1day.1 week Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-05-31 15:53 +0200
      Re: I need to get files with different timespan 1hr, 1day.1 week Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-05-31 10:08 -0400
        Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-05-31 22:02 -0700
        Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-05-31 22:08 -0700
          Re: I need to get files with different timespan 1hr, 1day.1 week Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-06-01 07:43 -0400
  Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-06-01 04:57 -0700
  Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-06-01 04:58 -0700
  Re: I need to get files with different timespan 1hr, 1day.1 week msr2858@gmail.com - 2018-06-01 05:00 -0700
    Re: I need to get files with different timespan 1hr, 1day.1 week Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-06-01 16:08 +0200

csiph-web