From: tcofoegbu Date: Tue, 26 Apr 2016 12:00:43 +0000 (+0100) Subject: JAL-2071 improvement to get column data files as InputStream X-Git-Tag: Release_2_10_0~250 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9259191d7265f8004f7cf51a62d9365a5c84067b;p=jalview.git JAL-2071 improvement to get column data files as InputStream --- diff --git a/src/jalview/fts/core/FTSRestClient.java b/src/jalview/fts/core/FTSRestClient.java index f611d5b..0605fef 100644 --- a/src/jalview/fts/core/FTSRestClient.java +++ b/src/jalview/fts/core/FTSRestClient.java @@ -5,8 +5,9 @@ import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI; import jalview.fts.api.FTSRestClientI; import java.io.BufferedReader; -import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Objects; @@ -43,7 +44,10 @@ public abstract class FTSRestClient implements FTSRestClientI public void parseDataColumnsConfigFile() { String fileName = getColumnDataConfigFileName(); - try (BufferedReader br = new BufferedReader(new FileReader(fileName))) + + InputStream in = getClass().getResourceAsStream(fileName); + + try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String line; while ((line = br.readLine()) != null) diff --git a/src/jalview/fts/service/pdb/PDBFTSRestClient.java b/src/jalview/fts/service/pdb/PDBFTSRestClient.java index 28e06d2..08803b0 100644 --- a/src/jalview/fts/service/pdb/PDBFTSRestClient.java +++ b/src/jalview/fts/service/pdb/PDBFTSRestClient.java @@ -413,7 +413,7 @@ public class PDBFTSRestClient extends FTSRestClient @Override public String getColumnDataConfigFileName() { - return getResourceFile("/fts/pdb_data_columns.txt"); + return "/fts/pdb_data_columns.txt"; } diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index 15c699e..c8e21e0 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -217,7 +217,7 @@ public class UniProtFTSRestClient extends FTSRestClient @Override public String getColumnDataConfigFileName() { - return getResourceFile("/fts/uniprot_data_columns.txt"); + return "/fts/uniprot_data_columns.txt"; } } diff --git a/test/jalview/fts/core/FTSRestClientTest.java b/test/jalview/fts/core/FTSRestClientTest.java index 4a90c4e..a5c6390 100644 --- a/test/jalview/fts/core/FTSRestClientTest.java +++ b/test/jalview/fts/core/FTSRestClientTest.java @@ -24,7 +24,7 @@ public class FTSRestClientTest @Override public String getColumnDataConfigFileName() { - return "examples/testdata/test_fts_data_columns.conf"; + return "/fts/uniprot_data_columns.txt"; } @Override @@ -272,7 +272,7 @@ public class FTSRestClientTest } String actualResourseFile = ftsRestClient - .getResourceFile("fts/uniprot_data_columns.conf"); + .getResourceFile("/fts/uniprot_data_columns.txt"); Assert.assertNotNull(actualResourseFile); Assert.assertTrue(actualResourseFile.length() > 31); }