-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweatherAnalyzer.java
More file actions
53 lines (46 loc) · 1.23 KB
/
weatherAnalyzer.java
File metadata and controls
53 lines (46 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.*;
import java.time.LocalDateTime;
import java.io.*;
public class weatherAnalyzer
{
public boolean snowCurrently()
{
Date date = new Date();
String dateString = date.toString();
File weatherFile = new File("output.csv");
if(!weatherFile.exists())
{
System.out.println("Error: Cannot find " + "output.csv" + ".");
return false;
}
Scanner fileScanner;
try
{
fileScanner = new Scanner(weatherFile).useDelimiter(",|\\r\\n");
}
catch (FileNotFoundException f)
{
System.out.println("Error: Cannot find " + "output.csv" + ".");
return false;
}
while(fileScanner.hasNext())
{
String csvTime = fileScanner.next();
String csvSnow = fileScanner.next();
//System.out.println("csvTime = " + csvTime +", dateString = " + dateString);
//System.out.println("csvTime substring= " + csvTime.substring(0,2) +", dateString substring= " + dateString.substring(11,13));
if(csvTime.substring(0,2).equals(dateString.substring(11,13)) && csvSnow.equals("True"))
return true;
}
fileScanner.close();
return false;
}
public weatherAnalyzer()
{
}
public static void main(String[] Args)
{
weatherAnalyzer wA = new weatherAnalyzer();
System.out.println(wA.snowCurrently());
}
}