一些非常有用的JAVA常用方法( 2)

int cInt(float stsid){
     int cInt = 0;
     try{
      int stsid1 = 0;
   if(stsid > 0){
      if((stsid - (int)stsid > 0) && (stsid - (int)stsid != 0.5))
         stsid1 = (int)(stsid + 0.5);
      if(stsid - (int)stsid == 0.5){
      if(((int)(stsid-0.5))%2 == 0)
         stsid1 = (int)(stsid - 0.5);
      else
            stsid1 = (int)(stsid + 0.5);
      }
            if(stsid - (int)stsid ==0)
      stsid1 = (int)stsid;
   }else{
      stsid = -stsid;
   if((stsid - (int)stsid > 0) && (stsid - (int)stsid != 0.5))
         stsid1 = - (int)(stsid + 0.5);
      if(stsid - (int)stsid == 0.5){
      if(((int)(stsid-0.5))%2 == 0)
         stsid1 = - (int)(stsid - 0.5);
      else
            stsid1 = - (int)(stsid + 0.5);
      }
            if(stsid - (int)stsid ==0)
      stsid1 = - (int)stsid;
   }
   cInt = stsid1;
  }catch(Exception e){}
  return cInt;
  }

时间: 2024-08-03 11:55:41

一些非常有用的JAVA常用方法( 2)的相关文章

一些非常有用的JAVA常用方法(1)

  作者:xiaoyou 出处: www.csdn.com<%!stc_RSYB_Name stcRSYName1[];stc_SYB_INF stcSYBINF1[];%><%/*   String p = (String) session.getValue("access");   if (p==null || !p.equals("1")) {     response.sendRedirect("error.htm");

java 常用方法 normalizeSpace

问题描述 java 常用方法 normalizeSpace Remove leading and trailing whitespace and then replacing sequences of whitespace characters. public static String normalizeSpace(String str) { } 要求:需要运行速度快 解决方案 public static final String EMPTY_STRING = """&qu

20个非常有用的Java程序片段

下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric string int i = Integer.parseInt(a); //numeric string to an int 2. 向文件末尾添加内容 BufferedWriter out = null; try { out = new BufferedWriter(new FileWriter("filen

分享非常有用的Java程序 (关键代码) (一)

原文:分享非常有用的Java程序 (关键代码) (一)    分享一些非常有用的Java程序 (关键代码) ,希望对你有所帮助. 1.  得到当前方法的名字 String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); 2. 转字符串到日期 java.util.Date = java.text.DateFormat.getDateInstance().parse(date String); 或者是:

分享非常有用的Java程序(关键代码)(七)---抓屏程序

原文:分享非常有用的Java程序(关键代码)(七)---抓屏程序  import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.File; ... public void captureScr

分享非常有用的Java程序(关键代码)(八)---Java InputStream读取网络响应Response数据的方法!(重要)

原文:分享非常有用的Java程序(关键代码)(八)---Java InputStream读取网络响应Response数据的方法!(重要)   Java InputStream读取数据问题 ====================================================================== 原理讲解  1. 关于InputStream.read()      在从数据流里读取数据时,为图简单,经常用InputStream.read()方法.这个方法是从流里每

分享非常有用的Java程序 (关键代码)(六)---解析/读取XML 文件(重要)

原文:分享非常有用的Java程序 (关键代码)(六)---解析/读取XML 文件(重要) XML文件 <?xml version="1.0"?> <students> <student> <name>John</name> <grade>B</grade> <age>12</age> </student> <student> <name>Mar

分享非常有用的Java程序 (关键代码) (三)---创建ZIP和JAR文件

原文:分享非常有用的Java程序 (关键代码) (三)---创建ZIP和JAR文件  import java.util.zip.*; import java.io.*; public class ZipIt { public static void main(String args[]) throws IOException { if (args.length < 2) { System.err.println("usage: java ZipIt Zip.zip file1 file2

分享非常有用的Java程序 (关键代码)(四)---动态改变数组的大小

原文:分享非常有用的Java程序 (关键代码)(四)---动态改变数组的大小  /** * Reallocates an array with a new size, and copies the contents * * of the old array to the new array. * * @param oldArray the old array, to be reallocated. * * @param newSize the new array size. * * @retur