Android 读取系统字体
package com.fonts.zsh;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class Android_fonts extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String output = "";
String filepath="/system/fonts";
File file=new File(filepath);
if(file.exists())
{
Log.d("............................................file","exists");
if(file.isFile()){
try{
BufferedReader input = new BufferedReader (new FileReader(file));
StringBuffer buffer = new StringBuffer();
String text;
while((text = input.readLine()) != null)
buffer.append(text +"/n");
output = buffer.toString();
}
catch(IOException ioException){
System.err.println("File Error!");
}
}
else if(file.isDirectory()){
String[] dir = file.list();
output += "Directory contents:/n :";
for(int i=0; i<dir.length; i++){
output += dir[i] +"#";
}
}
}
else
{
Log.d("............................................end","can not open");
}
Log.d("................................",output);
}
}