www.2015338.comjava.util.PropertyPermission.equals()方法实例

VIM ww9992019com 发表于 5 天前

www.2015338.com开户请拨15974937077湖北女子暴雨身亡成都武侯区l4mz5E<div style="width:100%;float:left;" class="article-content">

                <input type="hidden" name="article_id" id="article_id" value="4061">
                <input type="hidden" name="catid" id="catid" value="0">

                <p>

<strong>java.util.PropertyPermission.equals(Object obj) </strong>方法检查,如果这个对象是等于obj。也就是说,它具有相同的名称和动作与此对象</p>

<h2>

声明</h2>

<p>

以下是java.util.PropertyPermission.equals()方法的声明</p>

<pre class="prettyprint prettyprinted">

<span class="kwd">public</span><span class="pln"> </span><span class="kwd">boolean</span><span class="pln"> equals</span><span class="pun">(</span><span class="typ">Object</span><span class="pln"> obj</span><span class="pun">)</span></pre>

<h2>

参数</h2>

<ul>

<li>

    <p>

        obj -- 要检查的对象</p>

</li>

</ul>

<h2>

返回值</h2>

<p>

如果给定的对象等于此对象(即相同的名称和动作)此方法返回true。</p>

<h2>

异常</h2>

NA

<h2>

例子</h2>

<p>

下面的例子显示了java.util.PropertyPermission.equals(Object)方法的用法。</p>

<pre class="prettyprint prettyprinted">

<span class="kwd">package</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">yiibai</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">util</span><span class="pun">.</span><span class="typ">PropertyPermission</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">PropertyPermissionDemo</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

</span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="typ">PropertyPermission</span><span class="pln"> permission</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> main</span><span class="pun">(</span><span class="typ">String</span><span class="pun">[]</span><span class="pln"> args</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

  </span><span class="com">// Build property permissions collection</span><span class="pln">

  permission </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">PropertyPermission</span><span class="pun">(</span><span class="str">"java.home.usr"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"read"</span><span class="pun">);</span><span class="pln">



  </span><span class="com">// Check file read permissions</span><span class="pln">

  checkFileReadPermissions</span><span class="pun">(</span><span class="str">"java.home.usr"</span><span class="pun">);</span><span class="pln">

  </span><span class="com">// Check file write permissions</span><span class="pln">

  checkFileWritePermissions</span><span class="pun">(</span><span class="str">"java.home.usr"</span><span class="pun">);</span><span class="pln">

</span><span class="pun">}</span><span class="pln">

</span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> checkFileReadPermissions</span><span class="pun">(</span><span class="typ">String</span><span class="pln"> path</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

  </span><span class="com">// Check permissions are equal</span><span class="pln">

  </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">permission</span><span class="pun">.</span><span class="pln">equals</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> </span><span class="typ">PropertyPermission</span><span class="pun">(</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> </span><span class="str">"read"</span><span class="pun">)))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

     </span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"Has permissions on "</span><span class="pun">+</span><span class="pln">path</span><span class="pun">+</span><span class="str">" for read"</span><span class="pun">);</span><span class="pln">

  </span><span class="pun">}</span><span class="pln">

</span><span class="pun">}</span><span class="pln">

</span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> checkFileWritePermissions</span><span class="pun">(</span><span class="typ">String</span><span class="pln"> path</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

  </span><span class="com">// Check permissions are equal</span><span class="pln">

  </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">permission</span><span class="pun">.</span><span class="pln">equals</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> </span><span class="typ">PropertyPermission</span><span class="pun">(</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> </span><span class="str">"write"</span><span class="pun">)))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

     </span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"Has permissions on "</span><span class="pun">+</span><span class="pln">path</span><span class="pun">+</span><span class="str">" for write"</span><span class="pun">);</span><span class="pln">

  </span><span class="pun">}</span><span class="pln">

</span><span class="pun">}</span><span class="pln">

</span><span class="pun">}</span></pre>

<p>

让我们来编译和运行上面的程序,这将产生以下结果:</p>

<pre class="prettyprint prettyprinted">

<span class="typ">Has</span><span class="pln"> permissions on java</span><span class="pun">.</span><span class="pln">home</span><span class="pun">.</span><span class="pln">usr </span><span class="kwd">for</span><span class="pln"> read</span></pre>

                <br>
                <p style="text-align:center;float:left;width:100%;margin-top:24px;margin-bottom:18px;">
                        <button class="layui-btn layui-btn-danger" id="btn-reward"> ¥ 我要打赏 </button>  
                        <button class="layui-btn" id="article-perfect">
                            <i class="layui-icon layui-icon-edit"></i>教程纠错
                        </button>
                        <button class="layui-btn layui-btn-normal" id="action-collection">
                            <i class="layui-icon layui-icon-rate"></i>收藏
                        </button>
                </p>



                <div style="width:100%;margin-bottom: 16px; height: 32px;margin-top:18px;float:left;">

                    <span style="float:left;">上一篇:<a href="http://f2e.im/u/ww9992019com" title="java.util.Properties类"><i class="layui-icon"></i>
                            java.util.Properties类</a></span>
                                            <span style="float:right;">下一篇:<a href="http://f2e.im/u/ww9992019com" style="float:right;" title="下一篇:java.util.PropertyPermission.getActions()方法实例"><i class="layui-icon"></i>
                            java.util.PropertyPermission.getActions()方法实例</a></span>
                                            <div id="googlead" style="float:left;margin-top:8px;">
                        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                        <!-- yiibai下方 -->
                        <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1090193214637198" data-ad-slot="6494738921"></ins>
                        <script>
                            (adsbygoogle = window.adsbygoogle || []).push({});
                        </script>
                    </div>
                </div>

                <div style="width:100%;margin-top:18px;float:left;">


            </div>
暂无回复,说出你的观点吧
登录后即可参与回复