Str.java
上传用户:sxwtmm
上传日期:2022-08-11
资源大小:2183k
文件大小:2k
源码类别:

OA系统

开发平台:

Java

  1. /*
  2.  * Created on 2004-9-18
  3.  *
  4.  * To change the template for this generated file go to
  5.  * Window>Preferences>Java>Code Generation>Code and Comments
  6.  */
  7. package oa.sys;
  8. /**
  9.  ****************************************************
  10.  *类名称: Str<br>
  11.  *类功能: 字符串转换操作<br>
  12.  *创建: 白伟明 2004年9月23日<br>
  13.  ****************************************************
  14.  * To change the template for this generated type comment go to
  15.  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  16.  */
  17. public class Str {
  18. /**
  19.  * 
  20.  */
  21. public Str() {
  22. super();
  23. }
  24. /***************************************************
  25. *函数名称:chStr()<br>
  26. *函数功能:返回中文字符串<br>
  27. *返回值:  String<br>
  28. *参数说明:str<br>
  29. *最后修改:白伟明
  30. *    2004年8月17日
  31. ****************************************************/
  32. public String chStr(String str){
  33. if(str==null){
  34. str="";
  35. }else{
  36. try{
  37. str=(new String(str.getBytes("iso-8859-1"),"GB2312")).trim();
  38. }catch(Exception e){
  39. System.out.println("chStr");
  40. System.out.println(e.getMessage());
  41. }
  42. }
  43. return str;
  44. }
  45. /***************************************************
  46. *函数名称:inStr()<br>
  47. *函数功能:做编码一次转换,入库时防止sql攻击<br>
  48. *返回值:  String<br>
  49. *参数说明:str<br>
  50. *最后修改:白伟明
  51. *    2004年8月17日
  52. ****************************************************/
  53. public String inStr(String str){
  54. if(str==null){
  55. str="";
  56. }else{
  57. try{
  58. str=str.replace(''',(char)1).trim();
  59. }catch(Exception e){
  60. System.out.println("inStr");
  61. System.out.println(e.getMessage());
  62. }
  63. }
  64. return str;
  65. }
  66. /***************************************************
  67. *函数名称:outStr()<br>
  68. *函数功能:做编码二次转换,出库时防止Exception<br>
  69. *返回值:  String
  70. *    返回中文字符串<br>
  71. *参数说明:str<br>
  72. *最后修改:白伟明
  73. *    2004年8月17日
  74. ****************************************************/
  75. public String outStr(String str){
  76. if(str==null){
  77. str="";
  78. }else{
  79. try{
  80. str=str.replace((char)1,''').trim();
  81. }catch(Exception e){
  82. System.out.println("outStr");
  83. System.out.println(e.getMessage());
  84. }
  85. }
  86. return str;
  87. }
  88. }