简体   繁体   中英

make RESTful API call ONLY by calls in java.io

I was asked is there anyway to call RESTful API only by java.io. No java.net URL and 3rd party library. I did try to open HTTP by different reader/InputStream under java.io, it seems getting FileNotFoundExceptions, etc.

Any ideas?

According to the Java documentation:

Package java.io

Provides for system input and output through data streams, serialization and the file system.

In order to make a REST call using such such approach, you may write a REST method call into a JSON format and payload into a File then have a another application read the file that will then do the actual REST API call.

And since this is not a direct REST call, the answer to your question is that it's not possible not to use any networking module of the Java Platform to achieve what you require.

Although I wonder why you are restricted to use only java.io for REST API calls?

我认为它可以通过 OS 命令间接进行 RESTful 调用,例如编写 curl 脚本并使用 Process 来执行它,它将输出重定向到一个文件,然后读取输出文件以解析输出 JSON

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM