小代码合集

引用

数组转Arraylist


private static String[] items={"lorem", "ipsum", "dolor","sit", "amet", "consectetuer","adipiscing", "elit", "morbi","vel", "ligula", "vitae","arcu", "aliquet", "mollis","etiam", "vel", "erat","placerat", "ante","porttitor", "sodales","pellentesque", "augue","purus"}; 

ArrayList<String> itemStrs=new ArrayList(Arrays.asList(items));


引用

ArrayList转数组


	ArrayList<String> list=new ArrayList<String>();
		for(int i=0;i<5;i++){
			list.add("Number :"+(i+10));
		}
		String[] con=new String[list.size()];
		con=(String[]) list.toArray(new String[list.size()]);


引用

Java IOC

public class BeanUtils {

	private BeanUtils() {

	}
	
	public static Object getFiledValue(final Object object,
			final String fieldName){
		Field field=getDeclaredField(object,fieldName);
		if(field==null){
			throw new IllegalArgumentException("Could not find field["+fieldName+"] on target [ "+object+" ]");
		}
		makeAccessible(field);
		try {
			return field.get(object);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public static void setFieldValue(final Object object,
			final String fieldName, final Object value) {

		Field field = getDeclaredField(object, fieldName);

		if (field == null)
			throw new IllegalArgumentException("Could not find field ["
					+ fieldName + "] on target [" + object + "]");
		makeAccessible(field);
		try {
			field.set(object, value);
		} catch (IllegalAccessException e) {

		}
	}

	protected static Field getDeclaredField(final Object object,
			final String fieldName) {

		return getDeclaredField(object.getClass(), fieldName);

	}

	protected static Field getDeclaredField(final Class clazz,
			final String fieldName) {

		for (Class superClass = clazz; superClass != Object.class; superClass = superClass
				.getSuperclass()) {

			try {

				return superClass.getDeclaredField(fieldName);

			} catch (NoSuchFieldException e) {

			}
		}
		return null;
	}

	protected static void makeAccessible(Field field) {
		if (!Modifier.isPublic(field.getModifiers())
				|| !Modifier.isPublic(field.getDeclaringClass().getModifiers())) {
			field.setAccessible(true);
		}
	}
}


位于/data/misc/wifi/下

某某.conf,一般是wpa_supplicant.conf

你可能感兴趣的:(代码)