net.sf.okapi.common.Util.toURL()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(208)

本文整理了Java中net.sf.okapi.common.Util.toURL()方法的一些代码示例,展示了Util.toURL()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.toURL()方法的具体详情如下:
包路径:net.sf.okapi.common.Util
类名称:Util
方法名:toURL

Util.toURL介绍

[英]Creates a new URL object from a path or a URI string. This is a convenience wrapper to catch the various conversion exceptions.
[中]从路径或URI字符串创建新的URL对象。这是一个方便的包装器,用于捕获各种转换异常。

代码示例

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-verification-ui

  1. private void importConfiguration() {
  2. try {
  3. String[] paths = Dialogs.browseFilenames(shell, "Import Configuration", false, null,
  4. String.format("Quality Check Configurations (*%s)\tAll Files (*.*)", Parameters.FILE_EXTENSION),
  5. String.format("*%s\t*.*", Parameters.FILE_EXTENSION));
  6. if (paths == null) {
  7. return;
  8. }
  9. params.load(Util.toURL(paths[0]), false);
  10. setData();
  11. } catch (Throwable e) {
  12. Dialogs.showError(shell, "Error while saving configuration.\n" + e.getMessage(), null);
  13. }
  14. }

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-verification-ui

  1. private void loadConfiguration () {
  2. try {
  3. String[] paths = Dialogs.browseFilenames(shell, "Load Configuration", false, null,
  4. String.format("Quality Check Configurations (*%s)\tAll Files (*.*)", Parameters.FILE_EXTENSION),
  5. String.format("*%s\t*.*", Parameters.FILE_EXTENSION));
  6. if ( paths == null ) return;
  7. startWaiting("Loading configuration...");
  8. Parameters params = session.getParameters();
  9. params.load(Util.toURL(paths[0]), false);
  10. }
  11. catch ( Throwable e ) {
  12. Dialogs.showError(shell, "Error while saving configuration.\n"+e.getMessage(), null);
  13. }
  14. finally {
  15. stopWaiting();
  16. }
  17. }

代码示例来源:origin: net.sf.okapi.steps/okapi-step-searchandreplace-ui

  1. public void widgetSelected(SelectionEvent e) {
  2. FileDialog fd = new FileDialog(shell, SWT.OPEN);
  3. fd.setText("Import Search and Replace Options");
  4. String selected = fd.open();
  5. if ( selected != null ) {
  6. try {
  7. Parameters tmpParams = new Parameters();
  8. tmpParams.load(Util.toURL(selected), false);
  9. setData(tmpParams);
  10. }
  11. catch ( Throwable err ) {
  12. Dialogs.showError(shell, err.getMessage(), null);
  13. }
  14. }
  15. }
  16. });

相关文章