List of usage examples for com.google.common.io Resources toString
public static String toString(URL url, Charset charset) throws IOException
From source file:com.optimizely.ab.config.DatafileProjectConfigTestUtils.java
public static String noAudienceProjectConfigJsonV2() throws IOException { return Resources.toString(Resources.getResource("config/no-audience-project-config-v2.json"), Charsets.UTF_8);//from www . j a va2s . c o m }
From source file:com.spotify.helios.master.MasterService.java
private void logBanner() { try {/* w ww . j a v a 2 s.co m*/ final String banner = Resources.toString(Resources.getResource("master-banner.txt"), UTF_8); log.info("\n{}", banner); } catch (IllegalArgumentException | IOException ignored) { } }
From source file:com.optimizely.ab.config.DatafileProjectConfigTestUtils.java
public static String validConfigJsonV3() throws IOException { return Resources.toString(Resources.getResource("config/valid-project-config-v3.json"), Charsets.UTF_8); }
From source file:com.optimizely.ab.config.DatafileProjectConfigTestUtils.java
public static String noAudienceProjectConfigJsonV3() throws IOException { return Resources.toString(Resources.getResource("config/no-audience-project-config-v3.json"), Charsets.UTF_8);/*from ww w . j a v a2 s . com*/ }
From source file:com.optimizely.ab.config.DatafileProjectConfigTestUtils.java
public static String validConfigJsonV4() throws IOException { return Resources.toString(Resources.getResource("config/valid-project-config-v4.json"), Charsets.UTF_8); }
From source file:com.facebook.buck.features.go.GoDescriptors.java
private static String extractTestMainGenerator() { try {/*from w w w .j a v a 2 s . co m*/ return Resources.toString(Resources.getResource(GoDescriptors.class, TEST_MAIN_GEN_PATH), Charsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.optimizely.ab.config.DatafileProjectConfigTestUtils.java
public static String nullFeatureEnabledConfigJsonV4() throws IOException { return Resources.toString(Resources.getResource("config/null-featureEnabled-config-v4.json"), Charsets.UTF_8);/*from w ww .j a v a 2s . c o m*/ }
From source file:org.openqa.selenium.remote.codec.w3c.W3CHttpCommandCodec.java
private Map<String, ?> executeAtom(String atomFileName, Object... args) { try {// w w w . ja v a 2s. c o m String scriptName = "/org/openqa/selenium/remote/" + atomFileName; URL url = getClass().getResource(scriptName); String rawFunction = Resources.toString(url, StandardCharsets.UTF_8); String script = String.format("return (%s).apply(null, arguments);", rawFunction); return toScript(script, args); } catch (IOException | NullPointerException e) { throw new WebDriverException(e); } }
From source file:com.vladsch.idea.multimarkdown.settings.MultiMarkdownSettingsPanel.java
public MultiMarkdownSettingsPanel() { clearCustomCssButton.addActionListener(new ActionListener() { @Override/*from w w w. j av a 2 s .co m*/ public void actionPerformed(ActionEvent e) { textCustomCss.setText(""); } }); btnLoadDefault.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //String cssFileText = MultiMarkdownGlobalSettings.getInstance().getCssFileText(htmlThemeComboBox.getSelectedIndex()); //String base64Css = Base64.encodeBase64URLSafeString(MultiMarkdownGlobalSettings.getInstance().getCssText().getBytes(Charset.forName("utf-8"))); //String cssText = new String(Base64.decodeBase64(base64Css), Charset.forName("utf-8")); MultiMarkdownGlobalSettings settings = MultiMarkdownGlobalSettings.getInstance(); textCustomCss.setText((useOldPreviewCheckBox.isSelected() ? settings.getCssFileText(htmlThemeList.getSelectedIndex(), false) : (includesColorsCheckBox.isSelected() ? settings.getCssFileText(htmlThemeList.getSelectedIndex(), true) : "") + (includesLayoutCssCheckBox.isSelected() ? settings.getLayoutCssFileText() : "") + (includesHljsCssCheckBox.isSelected() && useHighlightJsCheckBox.isSelected() ? settings.getHljsCssFileText(htmlThemeList.getSelectedIndex(), true) : ""))); } }); showHtmlTextCheckBox.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { showHtmlTextStateChanged(); } }); showHtmlTextCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showHtmlTextStateChanged(); } }); focusEditorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textCustomCss.requestFocus(); } }); ItemListener itemListener1 = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateCustomCssControls(); } }; useCustomCssCheckBox.addItemListener(itemListener1); useHighlightJsCheckBox.addItemListener(itemListener1); textCustomCss.addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { super.documentChanged(e); updateCustomCssControls(); } }); if (MultiMarkdownGlobalSettings.getInstance().fxPreviewFailedBuild.isFailedBuild()) { // set it and disable useOldPreviewCheckBox.setSelected(true); useOldPreviewCheckBox.setEnabled(false); } updateUseOldPreviewControls(); ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateUseOldPreviewControls(); } }; useOldPreviewCheckBox.addItemListener(itemListener); includesColorsCheckBox.addItemListener(itemListener); includesHljsCssCheckBox.addItemListener(itemListener); includesLayoutCssCheckBox.addItemListener(itemListener); if (htmlThemeComboBox instanceof ComboBox) { ((JComboBox) htmlThemeComboBox).addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (((JComboBox) htmlThemeComboBox).getSelectedIndex() != htmlThemeList.getSelectedIndex()) { htmlThemeList.setSelectedIndex(((JComboBox) htmlThemeComboBox).getSelectedIndex()); } } }); htmlThemeList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (((JComboBox) htmlThemeComboBox).getSelectedIndex() != htmlThemeList.getSelectedIndex()) { ((JComboBox) htmlThemeComboBox).setSelectedIndex(htmlThemeList.getSelectedIndex()); } } }); } //tippingJarEditorPane.setText("" + // "<html>\n" + // " <head>\n" + // " <style>\n" + // " td { text-align: right; margin 0; padding 0 10px !important; }\n" + // " td.pic { width: 0; }\n" + // " p, table, tr, body, div { margin: 0 !important; padding: 0 !important; }\n" + // " table { /*border: 1px solid black;*/ width: 100%; float: right !important; }\n" + // " </style>\n" + // " </head>\n" + // " <body>\n" + // " <table>\n" + // " <tr>\n" + // " <td><b>If you like my work then please feel free to tip me.<br>I will view it as a show of appreciation and as a reward for my effort.</b></td>\n" + // " <td class=\"pic\"><a href=\"http://flattr.com/thing/4603764/vschidea-multimarkdown-on-GitHub\" title=\"Donate monthly to vsch using Flattr\"><img src=\"https://raw.githubusercontent.com/vsch/idea-multimarkdown/master/assets/images/flattr-tips.png\" border=\"0\" width=\"43\" height=\"53\" alt=\"Donate monthly to vsch using Flattr\" /></a></td>\n" + // " <td class=\"pic\"><a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NR7DAGTC8CXLU\" title=\"Donate once-off to vsch using Paypal\"><img src=\"https://raw.githubusercontent.com/vsch/idea-multimarkdown/master/assets/images/paypal-tips.png\" border=\"0\" width=\"43\" height=\"53\" alt=\"Donate once-off to vsch using Paypal\" /></a></td>\n" + // " </tr>\n" + // " </table>\n" + // " </body>\n" + // "</html>\n" + // ""); String htmlText = ""; try { htmlText = Resources.toString(getClass().getResource("/com/vladsch/idea/multimarkdown/NOTICE.html"), Charsets.UTF_8); } catch (IOException ex) { ex.printStackTrace(); } MultiMarkdownPreviewEditor.setStyleSheet(noticesEditorPane); noticesEditorPane.setText(htmlText); //tippingJarEditorPane.addHyperlinkListener(listener); noticesEditorPane.addHyperlinkListener(SettingsPanelImpl.getHyperLinkListenerBrowseUrl()); // we don't change these githubWikiLinksCheckBox.setEnabled(false); //githubWikiLinksLabel.setVisible(false); }
From source file:net.sourceforge.docfetcher.enums.SettingsConf.java
public static String loadHeaderComment() throws IOException { URL url = SettingsConf.class.getResource("settings-conf-header.txt"); return Resources.toString(url, Charsets.UTF_8); }