易截截图软件、单文件、免安装、纯绿色、仅160KB

java读取txt文本

  public List createArrayList(String FilePath,String FileName){
     List  list =new ArrayList();
  FileName=FilePath+"\\"+FileName;
  
  File file=new File(FileName);
  String encoding="GBK";//防止乱码 这编码需要根据自己的操作系统默认的编码来设置
  String str=null; 
  try{
   if(!file.exists()) file.createNewFile();
   FileInputStream fis= new FileInputStream(file);
   InputStreamReader read=new InputStreamReader(fis,encoding);
   BufferedReader br = new BufferedReader(read);
   while((str=br.readLine())!=null)
   {
     str=new String(str);
     str=str.substring(str.indexOf("--")+2);
    // System.out.println(str);
        list.add(str);
   }
   
   }catch(Exception ee){
    ee.getMessage();
   }
   
   return list;
  
    }// end mothod


相关文档:

java exception java异常汇总(3)

java exception 解决方案 - 我的异常网|异常|exception 770 - java.net.unknownhostException 771 - com.ibatis.struts.BeanActionException 772 - javax.servlet.jsp.JspException:Cannot find bean under name org.apache.struts.taglib.html.BEAN 773 - java.lang.NoClassDefFoundError:org apache commons lang Unhand ......

Java中的IO流知识总结(转)

总结一:
Java IO的一般使用原则:
一、按数据来源(去向)分类:
1、是文件: FileInputStream, FileOutputStream, FileReader, FileWriter
2、是byte[]:ByteArrayInputStream, ByteArrayOutputStream
3、是Char[]: CharArrayReader, CharArrayWriter
4、是String: StringBufferInputStream, StringReader, StringW ......

Java中的equals()和hashCode()方法

    在Java语言中,一般不需要自定义equals()和hashCode()这两个方法,当需要对对象的内容进行比较的时候,才需要这样两个方法。例如,需要把对象放入HashSet或者把对象作为key放入HashMap、 Hashtable时,如果不想把具有相同内容的两个对象作为两个对象来看待,就需要重定义这两个方法。这两个方法的使用是 ......

使用 Java Native Interface 的最佳实践

 Java™ 本机接口(Java Native Interface,JNI)是一个标准的 Java API,它支持将 Java 代码与使用其他编程语言编写的代码相集成。如果您希望利用已有的代码资源,那么可以使用 JNI 作为您工具包中的关键组件 —— 比如在面向服务架构(SOA)和基于云的系统中。但是,如果在使用时未注意某些事项,则 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号