/*
 * This file is part of Bisq.
 *
 * Bisq is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 *
 * Bisq is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Bisq. If not, see <http://www.gnu.org/licenses/>.
 */

package bisq.core.network.p2p.seed;

import bisq.core.app.BisqEnvironment;

import bisq.network.NetworkOptionKeys;
import bisq.network.p2p.NodeAddress;
import bisq.network.p2p.seed.SeedNodeRepository;

import javax.inject.Inject;
import javax.inject.Named;

import java.net.URL;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

public class DefaultSeedNodeRepository implements SeedNodeRepository {
    private static final Pattern pattern = Pattern.compile("^([a-z0-9]+\\.onion:\\d+)");
    private static final String ENDING = ".seednodes";
    private static final Collection<NodeAddress> cache = new HashSet<>();
    private final BisqEnvironment bisqEnvironment;
    private final String seedNodes;

    @Inject
    public DefaultSeedNodeRepository(BisqEnvironment environment,
                                     @Nullable @Named(NetworkOptionKeys.SEED_NODES_KEY) String seedNodes) {
        bisqEnvironment = environment;
        this.seedNodes = seedNodes;
    }

    private void reload() {

        // see if there are any seed nodes configured manually
        if(seedNodes != null && !seedNodes.isEmpty()) {
            cache.clear();
            Arrays.stream(seedNodes.split(",")).forEach(s -> cache.add(new NodeAddress(s)));

            return;
        }

        // else, we fetch the seed nodes from our resources
        try {
            // read appropriate file
            final URL file = DefaultSeedNodeRepository.class.getClassLoader().getResource(BisqEnvironment.getBaseCurrencyNetwork().name().toLowerCase() + ENDING);
            final BufferedReader seedNodeFile = new BufferedReader(new FileReader(file.getFile()));

            // only clear if we have a fresh data source (otherwise, an exception would prevent us from getting here)
            cache.clear();

            // refill the cache
            seedNodeFile.lines().forEach(s -> {
                final Matcher matcher = pattern.matcher(s);
                if(matcher.find())
                    cache.add(new NodeAddress(matcher.group(1)));
            });

            // filter
            cache.removeAll(bisqEnvironment.getBannedSeedNodes().stream().map(s -> new NodeAddress(s)).collect(Collectors.toSet()));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public Collection<NodeAddress> getSeedNodeAddresses() {
        if(cache.isEmpty())
            reload();

        return cache;
    }

    public boolean isSeedNode(NodeAddress nodeAddress) {
        if(cache.isEmpty())
            reload();
        return cache.contains(nodeAddress);
    }
}

@@ -937,30 +937,8 @@
 d;%0A%0A
-import java.net.URL;%0A%0A
 impo
@@ -979,37 +979,27 @@
 java.io.
-FileNotFoundException
+InputStream
 ;%0Aimport
@@ -1007,20 +1007,27 @@
 java.io.
-File
+InputStream
 Reader;%0A
@@ -2260,77 +2260,41 @@
     
-try %7B%0A            // read appropriate file%0A            final URL file
+final InputStream fileInputStream
  = D
@@ -2352,16 +2352,24 @@
 Resource
+AsStream
 (BisqEnv
@@ -2438,28 +2438,24 @@
 G);%0A        
-    
 final Buffer
@@ -2505,42 +2505,46 @@
 new 
-FileReader(file.getFile()
+InputStreamReader(fileInputStream
 ));%0A%0A
-    
     
@@ -2653,36 +2653,32 @@
 g here)%0A        
-    
 cache.clear();%0A%0A
@@ -2673,28 +2673,24 @@
 e.clear();%0A%0A
-    
         // r
@@ -2713,20 +2713,16 @@
         
-    
 seedNode
@@ -2749,20 +2749,16 @@
 (s -%3E %7B%0A
-    
         
@@ -2817,20 +2817,16 @@
         
-    
 if(match
@@ -2832,28 +2832,24 @@
 her.find())%0A
-    
             
@@ -2906,20 +2906,16 @@
         
-    
 %7D);%0A%0A   
@@ -2919,20 +2919,16 @@
         
-   
- 
 // filte
@@ -2929,20 +2929,16 @@
  filter%0A
-    
         
@@ -3062,95 +3062,8 @@
 ));%0A
-        %7D catch (FileNotFoundException e) %7B%0A            e.printStackTrace();%0A        %7D%0A
     

Use resourceAsStream so it works on files in .jar as well