服务器读取
import org.apache.struts.upload.FormFile;

FormFile phoneFile = excelActionForm.getPhoneFile();
        try {
          BufferedReader reader = new BufferedReader(new InputStreamReader(
              phoneFile.getInputStream()));
          StringBuffer content = new StringBuffer();
          String inLine;
          while ( (inLine = reader.readLine()) != null) {
            if (content.length()>0){
             content.append(",");
            }
            content.append(inLine);
          }
          request.setAttribute("phones", content.toString());
          reader.close();
        }
        catch (Exception ex1) {
          ex1.printStackTrace();
        }

本地读取
private StringBuffer getContent(String fileName) throws FileNotFoundException,
      IOException {
    String errorMessage;
    StringBuffer content = new StringBuffer();
    java.io.File file = new java.io.File(fileName);
    if (!file.exists()) {
      return null;
    }
    else if (file != null) {
      BufferedReader reader = new BufferedReader(new FileReader(file));
      String inLine = reader.readLine();
      while (inLine != null) {
        content.append(inLine);
        if (reader.read() != -1) {
          content.append(",");
        }
        inLine = reader.readLine();
      }
      return content;
    }
    else {
      return null;
    }
  }