小编Sae*_*umi的帖子

如何处理在php中写入文件的多个请求?

我有这个代码

<?php
    if (!file_exists($folderAddress . $_GET['name'] . '.json')) {
            //create file
            $myJson = fopen($folder.$_GET['name']. ".json", "w");        
            //get a context of a url 
            $ch = curl_init($myUrl);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $text = '';
            if( ($text = curl_exec($ch) ) === false)
            {
                die('fail');
            }
            // Close handle
            curl_close($ch); 
            //copy to json file
            $result = fwrite($myJson, $text);
            fclose($myJson);
            $t = time();
           //add update date to db
            if (!mysqli_query($con, "INSERT INTO test (name )
            VALUES ('$_GET['name]', '$t')")
            ) {
            echo $text;
            mysqli_close($con);
                die('');
            }
            //show …
Run Code Online (Sandbox Code Playgroud)

php

1
推荐指数
1
解决办法
936
查看次数

如何找到ExecutableElement的类名?

我正在写一个注释处理器,我PostConstruct只对方法使用注释。假设我有一个这样的课:

public MyClass{

   @PostConstruct
   public void onCreate(){

   }
}
Run Code Online (Sandbox Code Playgroud)

所以在我的注释处理器中,我可以获得onCreate方法:

   for (Element element : roundEnv.getElementsAnnotatedWith(PostConstruct.class)) {

            if (element.getKind() != ElementKind.METHOD) {
                return false;
            }
            ExecutableElement method = (ExecutableElement) element;

        }
Run Code Online (Sandbox Code Playgroud)

而且我还需要了解onCreate方法(MyClass)的类名,但ExecutableElement没有提供任何方法来做到这一点。还有其他实用程序类可以给我类名吗?

java annotation-processing

1
推荐指数
1
解决办法
568
查看次数

如何在TypeElement中查找带注释的方法?

假设我有这样的课程:

public class MyClass extends Ancestor{

    @MyAnnotation
    void doSomething(){
    }

    @MyAnnotation
    void doAnotherthing(String[] args){
    }

}

public class Ancestor{

    @MyAnnotation
    void doFirst(){
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的注释处理器中,我有TypeElement一个MyClass.

如何@MyAnnotation在两者MyClass及其祖先中找到带注释的方法?

(我知道这是可能的,RoundEnvironment但我不想使用它)

java annotation-processing

1
推荐指数
1
解决办法
1754
查看次数

如何忽略Okhttp中的SSL错误?

我已经安装并打开PacketCapture,然后当我使用Okhttp向服务器请求API时,出现此异常。

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)

是否可以忽略SSL错误?

java ssl android okhttp

1
推荐指数
1
解决办法
3771
查看次数

如何在Android Universal Image Loader中保存图像?

Lazy-List我使用此代码和我的图像存储在名为的文件夹中LazyList

ImageLoader imageLoader=new ImageLoader(context); imageLoader.DisplayImage(url, imageView);

但在Universal-Image-Loader我使用这个

 ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())    
            .build();
    ImageLoader.getInstance().init(config);
    img = (ImageView) this.findViewById(R.id.test_id);
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.displayImage(URL.RECIPE_IMG_URL,img);
Run Code Online (Sandbox Code Playgroud)

但每次使用互联网来获取图像,并没有我的形象店口ASLO任何文件夹中一次添加.diskCache(new UnlimitedDiscCache(new File("myFolder")))config ,但没有商店myFolder.任何想法?

android android-image android-lazyadapter android-imageview universal-image-loader

0
推荐指数
1
解决办法
4851
查看次数