standardtool

package mtool;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

public class StandardTool {
 
 BufferedReader mbr;
 BufferedWriter mbw;
 List<BufferedWriter> lsmbw;
 List<BufferedReader> lsmbr;
 
 public BufferedReader readText(String path) throws FileNotFoundException, UnsupportedEncodingException{
  File f = new File(path);
  FileInputStream fi = new FileInputStream(f);
  InputStreamReader isr = new InputStreamReader(fi,"UTF-8");
  mbr = new BufferedReader(isr);
  return mbr;
 }
 
 public List<BufferedReader> readText(List<String> path) throws FileNotFoundException, UnsupportedEncodingException{
  lsmbr = new ArrayList<BufferedReader>();
  for(int i=0;i<path.size()&&path!=null;i++){
   File f = new File(path.get(i));
   FileInputStream fi = new FileInputStream(f);
   InputStreamReader isr = new InputStreamReader(fi,"UTF-8");
   lsmbr.add(new BufferedReader(isr));
  }
  return lsmbr; 
 }
 
 public BufferedWriter writeText(String path) throws FileNotFoundException, UnsupportedEncodingException{
  File f = new File(path);
  FileOutputStream fo = new FileOutputStream(f);
  OutputStreamWriter osw = new OutputStreamWriter(fo,"UTF-8");
  mbw = new BufferedWriter(osw);
  return mbw;
 }
  
 public List<BufferedWriter> writeText(List<String> path) throws FileNotFoundException, UnsupportedEncodingException{
  lsmbw = new ArrayList<BufferedWriter>();
  for(int i=0;i<path.size()&&path!=null;i++){
   File f = new File(path.get(i));
   FileOutputStream fo = new FileOutputStream(f);
   OutputStreamWriter osw = new OutputStreamWriter(fo,"UTF-8");
   lsmbw.add(new BufferedWriter(osw));
  }
  return lsmbw;  
 }
 
 /**
  * initializing system std
  * @author jc08346
  */
 static PrintStream systemout;
 static PrintStream systemerr;
 static {
   System.out.println("saving system out&err\n");
   systemout = System.out;
   systemerr = System.err;
 }
 
 public void SetOut() throws FileNotFoundException{
  PrintStream out = new PrintStream(new File("rsc//out"));
  System.out.println("redirecting system out to rsc//out");
  System.setOut(out);
 } 
 public void SetOut(String s) throws FileNotFoundException{
  PrintStream out = new PrintStream(new File(s));
  System.out.println("redirecting system out to "+s);
  System.setOut(out);
 }
 public void SetErr() throws FileNotFoundException{
  PrintStream err = new PrintStream(new File("rsc//err"));
  System.out.println("redirecting system err to rsc//err");
  System.setErr(err);
 }
 public void SetErr(String s) throws FileNotFoundException{
  PrintStream err = new PrintStream(new File(s));
  System.out.println("redirecting system out to "+s);
  System.setErr(err);
 }
 public static void ResetOut(){
  System.setOut(systemout);
 }
 public static void ResetErr(){
  System.setErr(systemerr);
  List l = new ArrayList<Integer>();
 }
 
 /**
  * timer for performance testing
  * @author jc08346
  *
  */
 abstract class Timer<T>{
  T s,e;
  public abstract void tStart();
  public abstract void tEnd();
  public abstract T calc(T s, T e);
  public T tRs(){return calc(s,e); }
 }
 public Timer<Long> getTimer(){
  return new Timer<Long>(){
   public void tStart(){ s = System.currentTimeMillis(); }
   public void tEnd(){ e = System.currentTimeMillis(); }
   @Override
   public Long calc(Long s,Long e){ return (e-s); }
  };
 }
}

Java标准工具(Java Standard Tool)是指在Java开发环境中提供的一系列工具集,用于帮助开发人员进行Java应用程序的开发、构建、调试和优化等工作。 其中,常用的Java标准工具包括以下几个主要部分: 1. 编译器(javac):用于将Java源代码文件(.java文件)编译为Java字节码文件(.class文件),从而实现跨平台的特性。 2. Java虚拟机(java):用于执行Java字节码文件,并提供一系列运行时环境和功能支持。 3. Javadoc:用于生成Java源代码的API文档,开发人员可以根据代码中的注释信息自动生成API文档。 4. Jar打包工具(jar):用于将Java字节码文件和相关资源文件打包成可执行的Java归档文件(.jar文件),方便程序的发布和运行。 5. 调试工具(jdb):用于在开发过程中对Java应用程序进行调试,可以设置断点、查看变量值、单步执行等。 6. 性能监控工具(jconsole):用于监控和管理Java应用程序的性能状况,包括CPU使用率、内存占用等指标的监控。 7. 内存分析工具(jvisualvm):用于分析Java应用程序的内存使用情况,包括内存泄漏的检测和定位。 8. 压力测试工具(jmeter):用于对Java应用程序进行压力测试,模拟并发用户对系统的请求,评估系统的性能和稳定性。 总之,Java标准工具是Java开发者日常工作中不可或缺的一部分,通过使用这些工具,开发人员可以更加高效地进行Java应用程序的开发、调试和性能优化等工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值