File tree 5 files changed +30
-10
lines changed
src/main/java/com/cellar/advent
5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ dependencies {
16
16
17
17
test {
18
18
useJUnitPlatform()
19
- }
19
+ }
Original file line number Diff line number Diff line change 1
1
distributionBase =GRADLE_USER_HOME
2
2
distributionPath =wrapper/dists
3
- distributionUrl =https\://services.gradle.org/distributions/gradle-7.5.1 -bin.zip
3
+ distributionUrl =https\://services.gradle.org/distributions/gradle-7.6 -bin.zip
4
4
zipStoreBase =GRADLE_USER_HOME
5
5
zipStorePath =wrapper/dists
Original file line number Diff line number Diff line change 1
1
rootProject. name = ' AdventOfCode'
2
-
Original file line number Diff line number Diff line change 2
2
3
3
import static java .util .Comparator .reverseOrder ;
4
4
5
- import java .io .IOException ;
6
- import java .net .URISyntaxException ;
7
- import java .nio .file .Files ;
8
- import java .nio .file .Path ;
5
+ import com .cellar .advent .utils .AdventUtils ;
6
+
9
7
import java .util .ArrayList ;
10
8
import java .util .List ;
11
9
12
10
public class Main {
13
11
14
- public static void main (String [] args ) throws IOException , URISyntaxException {
15
- var file = Main .class .getClassLoader ().getResource ("calories.txt" );
16
- var lines = Files .readAllLines (Path .of (file .toURI ()));
12
+ public static void main (String [] args ) {
13
+ var lines = AdventUtils .getFileLines ("calories.txt" );
17
14
18
15
List <Long > calories = new ArrayList <>();
19
16
long newCalories = 0L ;
Original file line number Diff line number Diff line change
1
+ package com .cellar .advent .utils ;
2
+
3
+ import static java .util .Objects .requireNonNull ;
4
+
5
+ import java .io .IOException ;
6
+ import java .net .URISyntaxException ;
7
+ import java .nio .file .Files ;
8
+ import java .nio .file .Path ;
9
+ import java .util .List ;
10
+
11
+ public final class AdventUtils {
12
+
13
+ public static List <String > getFileLines (String resourceName ) {
14
+ var file = AdventUtils .class .getClassLoader ().getResource (resourceName );
15
+
16
+ try {
17
+ return Files .readAllLines (Path .of (requireNonNull (file ).toURI ()));
18
+ } catch (IOException | URISyntaxException e ) {
19
+ throw new RuntimeException (e );
20
+ }
21
+ }
22
+
23
+ private AdventUtils () {}
24
+ }
You can’t perform that action at this time.
0 commit comments