diff --git a/.gitignore b/.gitignore index b83d2226..b0978478 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,171 @@ -/target/ + +# Created by https://www.gitignore.io/api/maven,eclipse,intellij+all +# Edit at https://www.gitignore.io/?templates=maven,eclipse,intellij+all + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +.sts4-cache/ + +### Intellij+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin + .idea/sonarlint + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar + +# End of https://www.gitignore.io/api/maven,eclipse,intellij+all diff --git a/src/main/java/io/github/mivek/facade/MetarFacade.java b/src/main/java/io/github/mivek/facade/MetarFacade.java index d856dd4e..95e945c5 100644 --- a/src/main/java/io/github/mivek/facade/MetarFacade.java +++ b/src/main/java/io/github/mivek/facade/MetarFacade.java @@ -36,7 +36,7 @@ public Metar decode(final String pCode) throws ParseException { } @Override - public Metar retrieveFromAirport(final String pIcao) throws IOException, ParseException { + public Metar retrieveFromAirport(final String pIcao) throws ParseException, IOException { if (pIcao.length() != AbstractWeatherCodeFacade.ICAO) { throw new ParseException(ErrorCodes.ERROR_CODE_INVALID_ICAO); // $NON-NLS-1$ } @@ -45,11 +45,8 @@ public Metar retrieveFromAirport(final String pIcao) throws IOException, ParseEx URL url = new URL(website); URLConnection urlCo = url.openConnection(); try (BufferedReader br = new BufferedReader(new InputStreamReader(urlCo.getInputStream()))) { - String line = (String) br.lines().toArray()[1]; - br.close(); + String line = br.lines().toArray(String[]::new)[1]; return getParser().parse(line); - } catch (Exception e) { - throw e; } } diff --git a/src/main/java/io/github/mivek/facade/TAFFacade.java b/src/main/java/io/github/mivek/facade/TAFFacade.java index 1fd3f503..90efbe31 100644 --- a/src/main/java/io/github/mivek/facade/TAFFacade.java +++ b/src/main/java/io/github/mivek/facade/TAFFacade.java @@ -46,13 +46,9 @@ public TAF retrieveFromAirport(final String pIcao) throws IOException, URISyntax URL url = new URL(website); try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) { StringBuilder sb = new StringBuilder(); - String inputLine; // Throw the first line since it is not part of the TAF event. br.readLine(); - while ((inputLine = br.readLine()) != null) { - // Remove tabs and add line returns. - sb.append(inputLine.replaceAll("\\s{2,}", "")).append("\n"); - } + br.lines().forEach(currentLine -> sb.append(currentLine.replaceAll("\\s{2,}", "")).append("\n")); return getParser().parse(format(sb.toString())); } }