hudson.Util.changeExtension()方法的使用及代码示例

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

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

Util.changeExtension介绍

[英]Returns a file name by changing its extension.
[中]通过更改扩展名返回文件名。

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. protected void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst,".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if(!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename "+src+" to "+dst);
  12. }
  13. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. @Override
  6. protected void replace(File dst, File src) throws IOException {
  7. if (!site.getId().equals(ID_UPLOAD)) {
  8. verifyChecksums(this, plugin, src);
  9. }
  10. File bak = Util.changeExtension(dst, ".bak");
  11. bak.delete();
  12. final File legacy = getLegacyDestination();
  13. if (legacy.exists()) {
  14. if (!legacy.renameTo(bak)) {
  15. legacy.delete();
  16. }
  17. }
  18. if (dst.exists()) {
  19. if (!dst.renameTo(bak)) {
  20. dst.delete();
  21. }
  22. }
  23. if(!src.renameTo(dst)) {
  24. throw new IOException("Failed to rename "+src+" to "+dst);
  25. }
  26. }
  27. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public void downgade() throws IOException {
  2. File backupFile = Util.changeExtension(hpiArchive, ".bak");
  3. if (backupFile.exists()) {
  4. hpiArchive.delete();
  5. }
  6. if (!backupFile.renameTo(hpiArchive)) {
  7. throw new IOException("Failed to rename " + backupFile + " to " + hpiArchive);
  8. }
  9. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. /**
  2. * Called when the download is completed to overwrite the old file with
  3. * the new file.
  4. */
  5. protected void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst, ".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if (!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename " + src + " to " + dst);
  12. }
  13. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. /**
  2. * Called when the download is completed to overwrite the old file with the
  3. * new file.
  4. */
  5. private void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst, ".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if (!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename " + src + " to " + dst);
  12. }
  13. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. protected void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst,".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if(!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename "+src+" to "+dst);
  12. }
  13. }

代码示例来源:origin: hudson/hudson-2.x

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. protected void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst,".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if(!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename "+src+" to "+dst);
  12. }
  13. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. protected void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst,".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if(!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename "+src+" to "+dst);
  12. }
  13. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. protected void replace(File dst, File src) throws IOException {
  6. File bak = Util.changeExtension(dst,".bak");
  7. bak.delete();
  8. dst.renameTo(bak);
  9. dst.delete(); // any failure up to here is no big deal
  10. if(!src.renameTo(dst)) {
  11. throw new IOException("Failed to rename "+src+" to "+dst);
  12. }
  13. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public String getBackupVersion() throws IOException {
  2. File backupFile = Util.changeExtension(hpiArchive, ".bak");
  3. if (backupFile.exists()) {
  4. InstalledPluginInfo bakPluginInfo = new InstalledPluginInfo(backupFile);
  5. return bakPluginInfo.version;
  6. }
  7. return "";
  8. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. public boolean isDowngrdable() throws IOException {
  2. File backupFile = Util.changeExtension(hpiArchive, ".bak");
  3. if (backupFile.exists()) {
  4. InstalledPluginInfo bakPluginInfo = new InstalledPluginInfo(backupFile);
  5. return !bakPluginInfo.version.trim().equals(version);
  6. }
  7. return false;
  8. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. /**
  2. * Called when the download is completed to overwrite
  3. * the old file with the new file.
  4. */
  5. @Override
  6. protected void replace(File dst, File src) throws IOException {
  7. verifyChecksums(plugin.getSha1(), getComputedSHA1(), src);
  8. File bak = Util.changeExtension(dst, ".bak");
  9. bak.delete();
  10. final File legacy = getLegacyDestination();
  11. if (legacy.exists()) {
  12. if (!legacy.renameTo(bak)) {
  13. legacy.delete();
  14. }
  15. }
  16. if (dst.exists()) {
  17. if (!dst.renameTo(bak)) {
  18. dst.delete();
  19. }
  20. }
  21. if(!src.renameTo(dst)) {
  22. throw new IOException("Failed to rename "+src+" to "+dst);
  23. }
  24. }
  25. }

相关文章