Use the followingCodeGenerate the file name.
1 Package Info. haowei. util; 2 3 Import Java. Text. simpledateformat; 4 Import Java. util. date; 5 Import Java. util. Random; 6 7 Public Class Iptimestamp { 8 9 10 Private Simpledateformat SDF = Null ; 11 Private String IP =Null ; 12 13 14 Public Iptimestamp (string IP ){ 15 Super (); 16 17 This . IP = IP address; 18 } 19 20 21 Public Iptimestamp (){ 22 Super (); 23 } 24 25 26 Public String getiptimerand (){ 27 Stringbuffer Buf = New Stringbuffer (); 28 If ( This . IP! = Null ){ 29 String s [] = This . IP. Split ("\\." ); // Extract the numbers in the IP address based on the IP address. 30 For ( Int I = 0; I <S. length; I ++ ){ 31 Buf. append (This . Addzero (s [I], 3 ); // Zero of three digits 32 } 33 } 34 Buf. append ( This . Gettimestamp ()); 35 Random r = New Random (); // Add three random numbers at the end. 36 For ( Int I = 0; I <3; I ++ ){ 37 Buf. append (R. nextint (10 )); 38 } 39 Return Buf. tostring (); 40 } 41 42 Private String addzero (string STR, Int Len ){ 43 44 Stringbuffer S = New Stringbuffer (); 45 S. append (STR ); 46 While (S. Length () < Len ){ 47 S. insert (0, 0 ); 48 } 49 50 Return S. tostring (); 51 } 52 53 54 Private String gettimestamp () {// obtain the timestamp 55 This . SDF = New Simpledateformat ("yyyymmddhhmmsssss" ); 56 Return This . SDF. Format ( New Date ()); 57 } 58 59 Public String getdate (){ 60 This . SDF = New Simpledateformat ("yyyy-mm-dd hh: mm: Ss. Sss" ); 61 Return This . SDF. Format (New Date ()); 62 } 63 }