From 9259191d7265f8004f7cf51a62d9365a5c84067b Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 26 Apr 2016 13:00:43 +0100 Subject: [PATCH] JAL-2071 improvement to get column data files as InputStream --- src/jalview/fts/core/FTSRestClient.java | 8 ++++++-- src/jalview/fts/service/pdb/PDBFTSRestClient.java | 2 +- src/jalview/fts/service/uniprot/UniProtFTSRestClient.java | 2 +- test/jalview/fts/core/FTSRestClientTest.java | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) 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); } -- 1.7.10.2