• <i id='iVFW8'><tr id='iVFW8'><dt id='iVFW8'><q id='iVFW8'><span id='iVFW8'><b id='iVFW8'><form id='iVFW8'><ins id='iVFW8'></ins><ul id='iVFW8'></ul><sub id='iVFW8'></sub></form><legend id='iVFW8'></legend><bdo id='iVFW8'><pre id='iVFW8'><center id='iVFW8'></center></pre></bdo></b><th id='iVFW8'></th></span></q></dt></tr></i><div id='iVFW8'><tfoot id='iVFW8'></tfoot><dl id='iVFW8'><fieldset id='iVFW8'></fieldset></dl></div>

  • <legend id='iVFW8'><style id='iVFW8'><dir id='iVFW8'><q id='iVFW8'></q></dir></style></legend>
      <bdo id='iVFW8'></bdo><ul id='iVFW8'></ul>

    <small id='iVFW8'></small><noframes id='iVFW8'>

        <tfoot id='iVFW8'></tfoot>
      1. 获取Eclipse中当前编辑文件的绝对路径

        Get the absolute path of the currently edited file in Eclipse(获取Eclipse中当前编辑文件的绝对路径)

        <i id='928S9'><tr id='928S9'><dt id='928S9'><q id='928S9'><span id='928S9'><b id='928S9'><form id='928S9'><ins id='928S9'></ins><ul id='928S9'></ul><sub id='928S9'></sub></form><legend id='928S9'></legend><bdo id='928S9'><pre id='928S9'><center id='928S9'></center></pre></bdo></b><th id='928S9'></th></span></q></dt></tr></i><div id='928S9'><tfoot id='928S9'></tfoot><dl id='928S9'><fieldset id='928S9'></fieldset></dl></div>
        • <bdo id='928S9'></bdo><ul id='928S9'></ul>

              <tfoot id='928S9'></tfoot>

                  <tbody id='928S9'></tbody>
              • <legend id='928S9'><style id='928S9'><dir id='928S9'><q id='928S9'></q></dir></style></legend>

                <small id='928S9'></small><noframes id='928S9'>

                1. 本文介绍了获取Eclipse中当前编辑文件的绝对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想编写一个插件来处理当前在 Eclipse 中编辑的文件.但我不确定如何正确获取文件的完整路径.

                  I'd like to write a plugin that does something with the currently edited file in Eclipse. But I'm not sure how to properly get the file's full path.

                  这就是我现在所做的:

                  IFile file = (IFile) window.getActivePage().getActiveEditor.getEditorInput().
                      getAdapter(IFile.class);
                  

                  现在我有一个 IFile 对象,我可以检索它的路径:

                  Now I have an IFile object, and I can retrieve it's path:

                  file.getFullPath().toOSString();
                  

                  但是,这仍然只给了我相对于工作区的路径.我怎样才能从中获得绝对路径?

                  However this still only gives me the path relative to the workspace. How can I get the absolute path from that?

                  推荐答案

                  看起来你想要 IResource.getRawLocation().这会返回一个 IPath,如果你想更加确定你有一个绝对路径,它还有一个 makeAbsolute() 方法.

                  Looks like you want IResource.getRawLocation(). That returns an IPath, which also has a makeAbsolute() method if you want to be doubly sure you've got an absolute path.

                  这篇关于获取Eclipse中当前编辑文件的绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                  ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                  How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                  Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                  Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                  Why a sawtooth shaped graph?(为什么是锯齿形图形?)
                    <tbody id='IUTi9'></tbody>

                2. <small id='IUTi9'></small><noframes id='IUTi9'>

                  • <bdo id='IUTi9'></bdo><ul id='IUTi9'></ul>

                      <i id='IUTi9'><tr id='IUTi9'><dt id='IUTi9'><q id='IUTi9'><span id='IUTi9'><b id='IUTi9'><form id='IUTi9'><ins id='IUTi9'></ins><ul id='IUTi9'></ul><sub id='IUTi9'></sub></form><legend id='IUTi9'></legend><bdo id='IUTi9'><pre id='IUTi9'><center id='IUTi9'></center></pre></bdo></b><th id='IUTi9'></th></span></q></dt></tr></i><div id='IUTi9'><tfoot id='IUTi9'></tfoot><dl id='IUTi9'><fieldset id='IUTi9'></fieldset></dl></div>

                    1. <legend id='IUTi9'><style id='IUTi9'><dir id='IUTi9'><q id='IUTi9'></q></dir></style></legend>
                        • <tfoot id='IUTi9'></tfoot>