From 0c60e56b37036303343b2ffb50a15cc9e92c210f Mon Sep 17 00:00:00 2001 From: Fengchao Date: Wed, 7 Feb 2018 13:48:37 +0800 Subject: [PATCH] Fix a bug caused by failing to get the host name. --- src/main/java/proteomics/ECL2.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/proteomics/ECL2.java b/src/main/java/proteomics/ECL2.java index 8da56a3..0babed0 100644 --- a/src/main/java/proteomics/ECL2.java +++ b/src/main/java/proteomics/ECL2.java @@ -49,17 +49,21 @@ public static void main(String[] args) { logger.info("Author: Fengchao Yu. Email: fyuab@connect.ust.hk"); String dbName = null; + String hostName = "unknown-host"; try { - String hostName = InetAddress.getLocalHost().getHostName(); + hostName = InetAddress.getLocalHost().getHostName(); logger.info("Computer: {}.", hostName); + } catch (UnknownHostException ex) { + logger.warn("Cannot get the computer's name."); + } + + try { dbName = String.format(Locale.US, "ECL2.%s.%s.temp.db", hostName, new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Calendar.getInstance().getTime())); logger.info("Parameter file: {}.", parameter_path); logger.info("Spectra file: {}.", spectra_path); new ECL2(parameter_path, spectra_path, dbName); - } catch (UnknownHostException ex) { - logger.warn("Cannot get the computer's name."); } catch (IOException | MzXMLParsingException | JMzReaderException | ExecutionException | InterruptedException | ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException ex) { ex.printStackTrace(); logger.error(ex.toString());