更上一层楼-Android研发工程师高级进阶
Retrofit 解析 JSON 数据
Retrofit 2.0: The biggest update yet on the best HTTP Client Library for Android
Retrofit 2 — Upgrade Guide from 1.9
Retrofit 开发示例
Retrofit — Send Objects in Request Body
method POST must have a request body
Retrofit: API Integration Made Easy
问题分析总结
出现错误
java.lang.IllegalArgumentException: Unable to create call adapter for rx.Observable<java.util.List<com.coam.model.test.GithubUser>>
需要将rxjava结合到retrofit,在构建请求客户端的地方加上 .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 如下:
Retrofit retrofit = new Retrofit.Builder().baseUrl(ENDPOINT)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
//mService = retrofit.create(GithubAPIInterface.class);
return new GithubService(retrofit.create(GithubAPIInterface.class));
并在dependencies中引入
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
PHP读取软件接ln 的相对父路径问题
PHP读取软连接下的PHP程序使用 DIR 获取的相对路径,获取的父级目录是源文件的父级目录,若想获取软连接的父级目录,应使用 $_SERVER[“SCRIPT_FILENAME”]来获取当前脚本文件绝句路径再拼接
CGI, FastCGI, PHP-FPM, SPAWN-FCGI, Nginx 它们之间的关系
php fpm和fast-CGI有啥关系?而且还有一个疑问,就是PHP以CGI方式运行,请问以CGI方式运行到底是啥意思??
String[] aArray = new String[5];
String[] bArray = {"a","b","c", "d", "e"};
String[] cArray = new String[]{"a","b","c","d","e"};
int[] intArray = { 1, 2, 3, 4, 5 };
String intArrayString = Arrays.toString(intArray);
// print directly will print reference value
System.out.println(intArray);
// [I@7150bd4d
System.out.println(intArrayString);
// [1, 2, 3, 4, 5]
String[] stringArray = { "a", "b", "c", "d", "e" };
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray));
System.out.println(arrayList);
// [a, b, c, d, e]
String[] stringArray = { "a", "b", "c", "d", "e" };
boolean b = Arrays.asList(stringArray).contains("a");
System.out.println(b);
// true
int[] intArray = { 1, 2, 3, 4, 5 };
int[] intArray2 = { 6, 7, 8, 9, 10 };
// Apache Commons Lang library
int[] combinedIntArray = ArrayUtils.addAll(intArray, intArray2);
method(new String[]{"a", "b", "c", "d", "e"});
// containing the provided list of elements
// Apache common lang
String j = StringUtils.join(new String[] { "a", "b", "c" }, ", ");
System.out.println(j);
// a, b, c
String[] stringArray = { "a", "b", "c", "d", "e" };
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(stringArray));
String[] stringArr = new String[arrayList.size()];
arrayList.toArray(stringArr);
for (String s : stringArr)
System.out.println(s);
Set<String> set = new HashSet<String>(Arrays.asList(stringArray));
System.out.println(set);
//[d, e, b, c, a]
int[] intArray = { 1, 2, 3, 4, 5 };
ArrayUtils.reverse(intArray);
System.out.println(Arrays.toString(intArray));
//[5, 4, 3, 2, 1]
int[] intArray = { 1, 2, 3, 4, 5 };
int[] removed = ArrayUtils.removeElement(intArray, 3);//create a new array
System.out.println(Arrays.toString(removed));
One more – convert int to byte array
byte[] bytes = ByteBuffer.allocate(4).putInt(8).array();
for (byte t : bytes) {
System.out.format("0x%x ", t);
}
package crunchify.com.tutorial;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Crunchify.com
*/
public class CrunchifyIterateThroughList {
public static void main(String[] argv) {
// create list
List<String> CrunchifyList = new ArrayList<String>();
// add 4 different values to list
CrunchifyList.add("eBay");
CrunchifyList.add("Paypal");
CrunchifyList.add("Google");
CrunchifyList.add("Yahoo");
// iterate via "for loop"
System.out.println("==> For Loop Example.");
for (int i = 0; i < CrunchifyList.size(); i++) {
System.out.println(CrunchifyList.get(i));
}
// iterate via "New way to loop"
System.out.println("\n==> Advance For Loop Example..");
for (String temp : CrunchifyList) {
System.out.println(temp);
}
// iterate via "iterator loop"
System.out.println("\n==> Iterator Example...");
Iterator<String> CrunchifyIterator = CrunchifyList.iterator();
while (CrunchifyIterator.hasNext()) {
System.out.println(CrunchifyIterator.next());
}
// iterate via "while loop"
System.out.println("\n==> While Loop Example....");
int i = 0;
while (i < CrunchifyList.size()) {
System.out.println(CrunchifyList.get(i));
i++;
}
// collection stream() util: Returns a sequential Stream with this collection as its source
System.out.println("\n==> collection stream() util....");
CrunchifyList.forEach((temp) -> {
System.out.println(temp);
});
}
}
Java List For 循环 How to iterate through Java List? Five (5) ways to Iterate Through Loop in Java
Java程序员常犯的10个错误