List of usage examples for java.util.logging Logger getLogger
@CallerSensitive public static Logger getLogger(String name)
From source file:es.logongas.iothome.agent.ConfigLoader.java
public static Config getConfig(String fileName) { Config config;/*from w w w . j a v a 2s . c o m*/ InputStream inputStream = null; try { ObjectMapper objectMapper = new ObjectMapper(); inputStream = new BufferedInputStream(new FileInputStream(fileName)); config = (Config) objectMapper.readValue(inputStream, Config.class); return config; } catch (Exception ex) { throw new RuntimeException(ex); } finally { try { if (inputStream != null) { inputStream.close(); } } catch (IOException ex) { Logger.getLogger(Storage.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:deincraftlauncher.IO.download.FTPConnection.java
public static void connect() { if (connected) { return;//w w w.j ava 2 s . c o m } try { client.connect(FTPSync.getFtpServer()); client.enterLocalPassiveMode(); client.login(FTPSync.getFtpUsername(), FTPSync.getFtpPassword()); client.setFileType(FTP.BINARY_FILE_TYPE); } catch (IOException ex) { Logger.getLogger(FTPConnection.class.getName()).log(Level.SEVERE, null, ex); } connected = true; }
From source file:it.cnr.ilc.ilcioutils.IlcInputToString.java
/** * Convert an inputstream into a string/* w w w . j a v a2 s . com*/ * * @param is the inputstream * @return the string from the input */ public static String convertInputStreamToString(InputStream is) { StringWriter writer = new StringWriter(); String encoding = "UTF-8"; String message = ""; String theString = ""; try { IOUtils.copy(is, writer, encoding); theString = writer.toString(); } catch (Exception e) { message = "IOException in coverting the stream into a string " + e.getMessage(); Logger.getLogger(CLASS_NAME).log(Level.SEVERE, message); } //System.err.println("DDDD " + theString); IOUtils.closeQuietly(is); IOUtils.closeQuietly(writer); return theString; }
From source file:com.devdungeon.httpexamples.HttpGetExample.java
private static String get(String url) { HttpClient client = new DefaultHttpClient(); HttpParams params = client.getParams(); HttpConnectionParams.setConnectionTimeout(params, 1000 * 5); HttpConnectionParams.setSoTimeout(params, 1000 * 5); HttpGet request = new HttpGet(url); HttpResponse response = null;//from w w w. j a v a2 s . c om try { response = client.execute(request); } catch (IOException ex) { Logger.getLogger(HttpGetExample.class.getName()).log(Level.SEVERE, null, ex); } BufferedReader rd; String html = ""; String line = null; try { rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); while ((line = rd.readLine()) != null) { html += line + "\n"; } } catch (IOException ex) { Logger.getLogger(HttpGetExample.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedOperationException ex) { Logger.getLogger(HttpGetExample.class.getName()).log(Level.SEVERE, null, ex); } return html; }
From source file:com.cybernostics.jsp2thymeleaf.api.expressions.function.SymbolWriter.java
public static void write(Writer w, String s) { try {//from ww w. j a v a2 s . c o m w.write(symbolMap.getOrDefault(s, s)); } catch (IOException ex) { Logger.getLogger(SymbolWriter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:dao.PersonalGoalTxtDaoTest.java
@AfterClass public static void tearDownClass() { File file = new File(System.getProperty("user.dir") + fSeparator + "MyDiaryBook"); try {/* w w w.j a v a 2 s.co m*/ FileUtils.deleteDirectory(file); } catch (IOException ex) { Logger.getLogger(PersonalGoalTxtDaoTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.grosscommerce.ICEcat.utilities.Downloader.java
public static void download(String urlFrom, String login, String pwd, OutputStream destStream) throws Exception { try {// ww w .ja v a 2 s.c o m HttpURLConnection uc = prepareConnection(urlFrom, login, pwd); uc.connect(); if (uc.getResponseCode() != HttpURLConnection.HTTP_OK) { Logger.getLogger(Downloader.class.getName()).log(Level.INFO, "Error, code: {0}, message {1}", new Object[] { uc.getResponseCode(), uc.getResponseMessage() }); return; } BufferedInputStream is = null; if ((uc.getContentEncoding() != null && uc.getContentEncoding().toLowerCase().equals("gzip")) || uc.getContentType() != null && uc.getContentType().toLowerCase().contains("gzip")) { is = new BufferedInputStream(new GZIPInputStream(uc.getInputStream())); Logger.getLogger(Downloader.class.getName()).log(Level.INFO, "Will download gzip data from: {0}", urlFrom); } else { is = new BufferedInputStream(uc.getInputStream()); Logger.getLogger(Downloader.class.getName()).log(Level.INFO, "Will download not compressed data from:{0}", urlFrom); } StreamsHelper.copy(is, destStream); destStream.flush(); } catch (Exception ex) { Logger.getLogger(Downloader.class.getName()).log(Level.SEVERE, "URL: " + urlFrom, ex); throw ex; } }
From source file:aaa.DBOperations.java
protected static void openConnection() { try {//from w ww . ja v a 2s. c om try { Class.forName(Initialize.CLASS_NAME).newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { Logger.getLogger(DBOperations.class.getName()).log(Level.SEVERE, null, ex); } connection = (Connection) DriverManager.getConnection(Initialize.DB_URL, Initialize.USERNAME, Initialize.PASSWORD); } catch (SQLException ex) { Logger.getLogger(DBOperations.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.github.cc007.buildoffmanagermaven.utils.PersistencyHelper.java
public static boolean loadBuildOff() { BuildOff bo = null;//from ww w. j av a 2 s. co m boolean success = false; try { File boFile = new File(BuildOffManager.getPlugin().getDataFolder(), "BuildOff.json"); if (boFile.exists()) { String boString = FileUtils.readFileToString(boFile); Gson gson = new GsonBuilder().registerTypeAdapter(Location.class, new LocationAdapter()).create(); bo = gson.fromJson(boString, BuildOff.class); success = true; } } catch (IOException ex) { Logger.getLogger(PersistencyHelper.class.getName()).log(Level.SEVERE, null, ex); } BuildOffManager.getPlugin().setActiveBuildOff(bo); return success; }
From source file:com.devdungeon.httpexamples.DownloadFile.java
private static void download(String url, String filepath) { HttpClient client = new DefaultHttpClient(); HttpParams params = client.getParams(); HttpConnectionParams.setConnectionTimeout(params, 1000 * 5); HttpConnectionParams.setSoTimeout(params, 1000 * 5); HttpGet request = new HttpGet(url); HttpResponse response = null;//from ww w . j a v a2s . c o m try { response = client.execute(request); } catch (IOException ex) { Logger.getLogger(HttpGetExample.class.getName()).log(Level.SEVERE, null, ex); } BufferedReader rd; String line = null; try { rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); FileWriter fileWriter = new FileWriter(filepath); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); while ((line = rd.readLine()) != null) { bufferedWriter.write(line); bufferedWriter.newLine(); } bufferedWriter.close(); } catch (IOException ex) { Logger.getLogger(HttpGetExample.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedOperationException ex) { Logger.getLogger(HttpGetExample.class.getName()).log(Level.SEVERE, null, ex); } }