List of usage examples for com.google.common.base Charsets ISO_8859_1
Charset ISO_8859_1
To view the source code for com.google.common.base Charsets ISO_8859_1.
Click Source Link
From source file:com.cloudbees.sdk.Tool.java
public static void main(String[] args) throws Exception { Map<String, Account> accountsById = new HashMap<String, Account>(); {//from w w w . j av a2s . c om List<String> lines = Resources.readLines( Thread.currentThread().getContextClassLoader().getResource("account-databases.txt"), Charsets.ISO_8859_1); for (String line : lines) { String[] splitted = line.split(" "); String accountId = splitted[0]; Account account = accountsById.get(accountId); if (account == null) { account = new Account(); account.accountId = accountId; accountsById.put(account.accountId, account); } for (int i = 1; i < splitted.length; i++) { account.databases.add(splitted[i]); } } } { List<String> lines = Resources.readLines( Thread.currentThread().getContextClassLoader().getResource("account-emails.txt"), Charsets.ISO_8859_1); for (String line : lines) { String[] splitted = line.split(" "); String accountId = splitted[0]; Account account = accountsById.get(accountId); if (account == null) { account = new Account(); account.accountId = accountId; accountsById.put(account.accountId, account); } for (int i = 1; i < splitted.length; i++) { account.emails.add(splitted[i]); } } } for (Account account : accountsById.values()) { for (String email : account.emails) { System.out .println(email + "\t" + account.accountId + "\t" + Joiner.on(", ").join(account.databases)); } } }
From source file:io.warp10.continuum.Fetch.java
public static void main(String[] args) throws Exception { URL url = new URL(args[0]); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(false);/* w w w.jav a 2 s .c om*/ conn.setDoInput(true); String psk = System.getProperty(Configuration.CONFIG_FETCH_PSK); if (null != psk) { String token = System.getProperty("fetch.token"); long now = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(Long.toHexString(now)); sb.append(":"); byte[] fetchKey = Hex.decode(psk); long hash = SipHashInline.hash24(fetchKey, (Long.toString(now) + ":" + token).getBytes(Charsets.ISO_8859_1)); sb.append(Long.toHexString(hash)); conn.setRequestProperty(Constants.getHeader(Configuration.HTTP_HEADER_FETCH_SIGNATURE), sb.toString()); } InputStream in = conn.getInputStream(); byte[] buf = new byte[8192]; while (true) { int len = in.read(buf); if (len <= 0) { break; } System.out.write(buf, 0, len); } System.out.flush(); conn.disconnect(); }
From source file:fr.xebia.demo.amazon.aws.AmazonAwsSesEmailVerifier.java
public static void main(String[] args) throws Exception { InputStream credentialsAsStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("AwsCredentials.properties"); Preconditions.checkNotNull(credentialsAsStream, "File 'AwsCredentials.properties' NOT found in the classpath"); AWSCredentials awsCredentials = new PropertiesCredentials(credentialsAsStream); AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient(awsCredentials); URL emailsToVerifyURL = Thread.currentThread().getContextClassLoader().getResource("emails-to-verify.txt"); List<String> emailsToVerify = Resources.readLines(emailsToVerifyURL, Charsets.ISO_8859_1); for (String emailToVerify : emailsToVerify) { System.out.println(emailToVerify); Thread.sleep(10 * 1000);//from www . j a v a2 s. com ses.verifyEmailAddress(new VerifyEmailAddressRequest().withEmailAddress(emailToVerify)); } }
From source file:net.liuxuan.device.VACVBS.VACVBSInfoMetaData.java
public static void main(String[] args) throws IOException { // VACVBSMetaData meta = new VACVBSMetaData(); // meta.HP = 100; // meta.Humidity = 20; // meta.LP = 200; // meta.Temprature = 100; // meta.Time = 3; //// meta.date1=""; // meta.date1 = new Date(); // meta.num = 0; // meta.reserved1 = 0; ///*ww w . j a v a 2s . c o m*/ Gson gson = new Gson(); // String a = gson.toJson(meta); // System.out.println(a); // String b = "{ \"num\":\"0\", \"HP\":\"0\", \"LP\":\"10\", \"Humidity\":\"39\", \"Temprature\":\"23.5\", \"date1\":\"2014-8-16 16:27:54 \", \"Time\":\"6\"}"; // VACVBSMetaData d =gson.fromJson(b, VACVBSMetaData.class); // System.out.println(d.LP); // System.out.println(d.date1); File filea = new File( "F:\\MosesData\\Desktop\\?\\VAC-VBS data\\VBS\\\\bbb.VBSGTR.txt"); String fileContent = Files.toString(filea, Charsets.ISO_8859_1); // System.out.println(fileContent); VACVBSInfoMetaData imd = gson.fromJson(fileContent, VACVBSInfoMetaData.class); System.out.println(imd.Device); System.out.println(imd.datas.size()); System.out.println(imd.datas.get(0).date1); // JsonParser parser = new JsonParser(); // JsonElement je = parser.parse(fileContent); // // JsonArray array = je.getAsJsonArray(); // System.out.println(array.size()); }
From source file:com.cloudbees.api.Main.java
public static void main(String[] args) throws Exception { File beesCredentialsFile = new File(System.getProperty("user.home"), ".bees/bees.config"); Preconditions.checkArgument(beesCredentialsFile.exists(), "File %s not found", beesCredentialsFile); Properties beesCredentials = new Properties(); beesCredentials.load(new FileInputStream(beesCredentialsFile)); String apiUrl = "https://api.cloudbees.com/api"; String apiKey = beesCredentials.getProperty("bees.api.key"); String secret = beesCredentials.getProperty("bees.api.secret"); BeesClient client = new BeesClient(apiUrl, apiKey, secret, "xml", "1.0"); client.setVerbose(false);/*from w ww . j av a 2 s. c o m*/ URL databasesUrl = Thread.currentThread().getContextClassLoader().getResource("databases.txt"); Preconditions.checkNotNull(databasesUrl, "File 'databases.txt' NOT found in the classpath"); Collection<String> databaseNames; try { databaseNames = Sets.newTreeSet(Resources.readLines(databasesUrl, Charsets.ISO_8859_1)); } catch (Exception e) { throw Throwables.propagate(e); } databaseNames = Collections2.transform(databaseNames, new Function<String, String>() { @Nullable @Override public String apply(@Nullable String input) { // {host_db_create,<<"tco_q5rm">>,<<"TCO_q5rm">>, if (input == null) return null; if (input.startsWith("#")) return null; if (input.indexOf('"') == -1) { logger.warn("Skip invalid line {}", input); return null; } input = input.substring(input.indexOf('"') + 1); if (input.indexOf('"') == -1) { logger.warn("Skip invalid line {}", input); return null; } return input.substring(0, input.indexOf('"')); } }); databaseNames = Collections2.filter(databaseNames, new Predicate<String>() { @Override public boolean apply(@Nullable String s) { return !Strings.isNullOrEmpty(s); } }); Multimap<String, String> databasesByAccount = ArrayListMultimap.create(); Class.forName("com.mysql.jdbc.Driver"); for (String databaseName : databaseNames) { try { DatabaseInfo databaseInfo = client.databaseInfo(databaseName, true); databasesByAccount.put(databaseInfo.getOwner(), databaseInfo.getName()); logger.debug("Evaluate " + databaseInfo.getName()); if (true == false) { // Hibernate logger.info("Hibernate {}", databaseName); Map<String, String> params = new HashMap<String, String>(); params.put("database_id", databaseName); String url = client.getRequestURL("database.hibernate", params); String response = client.executeRequest(url); DatabaseInfoResponse apiResponse = (DatabaseInfoResponse) client.readResponse(response); logger.info("DB {} status: {}", apiResponse.getDatabaseInfo().getName(), apiResponse.getDatabaseInfo().getStatus()); } if (true == false) { // Hibernate logger.info("Activate {}", databaseName); Map<String, String> params = new HashMap<String, String>(); params.put("database_id", databaseName); String url = client.getRequestURL("database.activate", params); String response = client.executeRequest(url); DatabaseInfoResponse apiResponse = (DatabaseInfoResponse) client.readResponse(response); logger.info("DB {} status: {}", apiResponse.getDatabaseInfo().getName(), apiResponse.getDatabaseInfo().getStatus()); } String dbUrl = "jdbc:mysql://" + databaseInfo.getMaster() + "/" + databaseInfo.getName(); logger.info("Connect to {} user={}", dbUrl, databaseInfo.getUsername()); Connection cnn = DriverManager.getConnection(dbUrl, databaseInfo.getUsername(), databaseInfo.getPassword()); cnn.setAutoCommit(false); cnn.close(); } catch (Exception e) { logger.warn("Exception for {}", databaseName, e); } } System.out.println("OWNERS"); for (String account : databasesByAccount.keySet()) { System.out.println(account + ": " + Joiner.on(", ").join(databasesByAccount.get(account))); } }
From source file:net.liuxuan.device.w3330.DataParseDrop.java
public static void main(String[] args) { // String s = "[2014-06-09 14:01:21#] _ppm:11.170 rezero:0.000 flux:0.0 ppm:0.000 wvtr:0.0000 temp1:38.000 temp2:900.100 temp3:24.200 status:0.0 "; // parsestr(s); FileWriter fw = null;//w w w . j a va 2 s . co m try { fw = new FileWriter(new File("d:/aaaa.txt")); } catch (IOException ex) { Logger.getLogger(DataParseDrop.class.getName()).log(Level.SEVERE, null, ex); } SimpleDateFormat sdfx = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss#]"); ExtensionFileFilter filter = new ExtensionFileFilter("log,txt", true, true); filter.setDescription("?"); JFileChooser jfc = new JFileChooser(); FileSystemView fsv = FileSystemView.getFileSystemView(); //? jfc.setCurrentDirectory(fsv.getHomeDirectory()); jfc.setDialogTitle("?"); jfc.setMultiSelectionEnabled(false); jfc.setDialogType(JFileChooser.OPEN_DIALOG); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);//JFileChooser.FILES_AND_DIRECTORIES jfc.setFileFilter(filter); int result = jfc.showOpenDialog(null); // ""? // String content; List<String> fileContentStringList = null; if (result == JFileChooser.APPROVE_OPTION) { // String filepath = jfc.getSelectedFile().getAbsolutePath(); if (jfc.getSelectedFile() == null) { // System.out.println("!!"); return; } try { fileContentStringList = Files.readLines(jfc.getSelectedFile(), Charsets.ISO_8859_1); } catch (IOException ex) { Logger.getLogger(JIF_DrawChart_w3330.class.getName()).log(Level.SEVERE, null, ex); } // content = FilePlus.ReadTextFileToString(new File(filepath), "\r\n", "utf-8"); } else { // content = null; System.out.println("!!"); return; } // String[] sa = content.split("\r\n"); String[] sa = (String[]) fileContentStringList.toArray(new String[fileContentStringList.size()]); // int startno = 0; while (!sa[startno].startsWith("[")) { startno++; } //?? try { Date starttime = sdfx.parse(sa[startno]); double current[] = new double[9]; double max[] = new double[9]; int count = 0; for (int indexi = startno; indexi < sa.length; indexi++) { // for (int i = startno; i < startno + 1; i++) { String s = sa[indexi]; if (s.startsWith("[")) { Date time = sdfx.parse(s); //"[2014-06-09 14:01:21#] _ppm:11.170 rezero:0.000 flux:0.0 ppm:0.000 wvtr:0.0000 temp1:38.000 temp2:900.100 temp3:24.200 status:0.0 "; // double wppm = 0; // double zero = 0; // double flux = 0; // double ppmzero = 0; // double wvtr = 0; // double temp1 = 0; // double temp2 = 0; // double temp3 = 0; // double status = 0; s = s.substring(s.indexOf("_ppm")).trim();//_ppm? // System.out.println(s); String[] sl = s.split("\\s+");// // System.out.println(sl.length); if (sl.length == 9) { count++; //9?? //? for (int j = 0; j < sl.length; j++) { // String string = sl[j]; current[j] = Double.parseDouble(sl[j].substring(sl[j].indexOf(":") + 1)); max[j] = current[j] > max[j] ? current[j] : max[j]; } // wppm = Double.parseDouble(sl[0].substring(sl[0].indexOf(":") + 1)); // zero = Double.parseDouble(sl[1].substring(sl[1].indexOf(":") + 1)); // flux = Double.parseDouble(sl[2].substring(sl[2].indexOf(":") + 1)); // ppmzero = Double.parseDouble(sl[3].substring(sl[3].indexOf(":") + 1)); // wvtr = Double.parseDouble(sl[4].substring(sl[4].indexOf(":") + 1)); // temp1 = Double.parseDouble(sl[5].substring(sl[5].indexOf(":") + 1)); // temp2 = Double.parseDouble(sl[6].substring(sl[6].indexOf(":") + 1)); // temp3 = Double.parseDouble(sl[7].substring(sl[7].indexOf(":") + 1)); // status = Double.parseDouble(sl[8].substring(sl[8].indexOf(":") + 1)); if ((count - 1) % 30 == 0 || indexi > sa.length - 3) { StringBuilder sb1 = new StringBuilder(); sb1.append(sa[indexi].substring(0, sa[indexi].indexOf("] ") + 2)); for (int j = 0; j < 8; j++) { sb1.append(sl[j].substring(0, sl[j].indexOf(":") + 1)); sb1.append(String.format("%.3f ", max[j])); } sb1.append(sl[8].substring(0, sl[8].indexOf(":") + 1)); sb1.append(String.format("%.1f ", max[8])); sb1.append("\r\n"); // System.out.println(sb1); fw.append(sb1); for (int j = 0; j < max.length; j++) { max[j] = -100; } } } } } } catch (ParseException ex) { // System.out.println(s); ex.printStackTrace(); } catch (IOException ex) { Logger.getLogger(DataParseDrop.class.getName()).log(Level.SEVERE, null, ex); } try { fw.flush(); fw.close(); } catch (IOException ex) { Logger.getLogger(DataParseDrop.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.c4om.autoconf.ulysses.configanalyzer.launcher.ConfigurationAnalysisLauncher.java
public static void main(String[] args) throws Exception { if (args.length < 4) { throw new IllegalArgumentException("Not enough arguments"); }//from w ww . j a v a 2 s . c o m final String appName = "testApp"; Environment environment = new Environment(); environment.getApplicationConfigurations().put(appName, URI.create(args[1])); Application testApplication = new Application(); testApplication.setName(appName); testApplication.getHosts().add("localhost"); for (int i = 2; i < args.length; i++) { testApplication.getConfigurationURIs().add(URI.create(args[i])); } Map<String, Application> parameters = new HashMap<>(); parameters.put(appName, testApplication); Target target = new ConfigureAppsTarget("configureTestApp", parameters); Map<String, Target> targets = new HashMap<String, Target>(); targets.put(target.getName(), target); Properties configurationAnalyzerSettings = new Properties(); InputStream configurationAnalyzerSettingsIS = ConfigurationAnalysisLauncher.class.getClassLoader() .getResourceAsStream(args[0]); if (configurationAnalyzerSettingsIS == null) { configurationAnalyzerSettingsIS = new FileInputStream(new File(args[0])); } configurationAnalyzerSettings .load(new InputStreamReader(configurationAnalyzerSettingsIS, Charsets.ISO_8859_1)); Analyzer analyzer = new ConfigurationAnalyzer(configurationAnalyzerSettings); AnalysisResults results = analyzer.analyze(targets, environment); System.out.println(results.toString()); System.exit(0); }
From source file:main.ColorMapExplorer.java
/** * @param args (ignored)/*from w w w . jav a2 s .c o m*/ */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) // admittedly, this is horrible, but we don't really care about l&f { logger.error("Cannot set look & feel", e); } List<Colormap2D> colorMaps = ColorMapFinder.findInPackage("colormaps.impl"); BibTeXDatabase database = new BibTeXDatabase(); try (InputStream bibtex = ColorMapExplorer.class.getResourceAsStream("/latex/colorBib.bib")) { BibTeXParser bibtexParser = new BibTeXParser(); InputStreamReader reader = new InputStreamReader(bibtex, Charsets.ISO_8859_1); database = bibtexParser.parse(reader); } catch (IOException e) { logger.error("Could not open bibtex file", e); } catch (TokenMgrException | ParseException e) { logger.error("Could not parse bibtex file", e); } ColorMapExplorer frame = new ColorMapExplorer(colorMaps, database); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(728, 600); frame.setLocationByPlatform(true); frame.setVisible(true); }
From source file:de.fhg.igd.iva.explorer.main.ColorMapExplorer.java
/** * @param args (ignored)/*from ww w . ja va 2 s . c o m*/ */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) // admittedly, this is horrible, but we don't really care about l&f { logger.error("Cannot set look & feel", e); } List<KnownColormap> colorMaps = discoverColormaps(); BibTeXDatabase database = new BibTeXDatabase(); try (InputStream bibtex = ColorMapExplorer.class.getResourceAsStream("/latex/colorBib.bib"); InputStreamReader reader = new InputStreamReader(bibtex, Charsets.ISO_8859_1)) { BibTeXParser bibtexParser = new BibTeXParser(); database = bibtexParser.parse(reader); } catch (IOException e) { logger.error("Could not open bibtex file", e); } catch (TokenMgrException | ParseException e) { logger.error("Could not parse bibtex file", e); } ColorMapExplorer frame = new ColorMapExplorer(colorMaps, database); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1280, 855); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:org.gradle.internal.util.PropertiesUtils.java
/** * Writes {@link java.util.Properties} in a way that the results can be expected to be reproducible. * * Uses defaults for the arguments of {@link PropertiesUtils#store(Properties, File, String, Charset, String)}: * <ul>/*from w w w . j av a 2 s . com*/ * <li>no comment</li> * <li>line separator {@literal '\n'}</li> * <li>charset ISO-8859-1</li> * </ul> */ public static void store(Properties properties, File propertyFile) throws IOException { store(properties, propertyFile, null, Charsets.ISO_8859_1, "\n"); }