Created
April 8, 2013 10:38
-
-
Save blackraccoon000/5335857 to your computer and use it in GitHub Desktop.
*1 動作失敗。 ロジック考え中 取得した文字列をsplitで分割して成形する->IPアドレスの形へという目的 **2戻り値を複数返すテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataTest { | |
static int[] init(){ | |
int data[] = new int[2]; | |
data[0] = 10; | |
data[1] = 19; | |
return data; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Exe { | |
public static void main(String args[]){ | |
int data[]; | |
data = DataTest.init(); | |
System.out.println(data.length); | |
System.out.println(data[0]); | |
System.out.println(data[1]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package snmpfirst.SplitTest; | |
//import java.util.regex.Pattern; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Yutaka Fujii | |
* Date: 13/04/08 | |
* Time: 10:36 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class StringSplit { | |
void splitMethod(String argument){ | |
// "/"のあるなしによって、ネットワークを分割する | |
String[] sp0 = argument.split("\\/"); | |
for(int i=0;i<sp0.length;i++){ | |
System.out.println(i+": "+sp0[i]); | |
} | |
System.out.println("========================1"); | |
// ネットワーク事にネットワークアドレス、ホストアドレスを分割する。 | |
String[] sp1; | |
String[] sp2; | |
String[] sp3; | |
for(int i=0;i<sp0.length;i++){ | |
sp1 = sp0[i].split("\\."); | |
for(int j=0;j<sp1.length;j++){ | |
if(j-3 != 0){ | |
// StringBuffer sb1 = new StringBuffer(sp1[0]); | |
// sb1.append(sp1[j+1]); | |
// System.out.println(sb1); | |
System.out.println("i"+i+": "+"j"+j+": "+sp1[j]); | |
} | |
if(j-3 == 0){ | |
sp2 = sp1[j].split("\\,"); | |
for(int k=0;k<sp2.length;k++){ | |
// System.out.println("k"+k+": "+sp2[k]); | |
if(sp2[k].matches(".*-.*")){ | |
sp3 = sp2[k].split("-"); | |
for(int l=0;l<sp3.length;l++){ | |
System.out.println("i"+i+": "+"j"+j+": "+"k"+k+": "+"l"+l+": "+sp3[l]); | |
} | |
} else { | |
System.out.println("i"+i+": "+"j"+j+": "+"k"+k+": "+sp2[k]); | |
} | |
} | |
} | |
} | |
} | |
// StringBuffer octAddress = new StringBuffer(sp1[0]); | |
// sp2分割確認済み | |
// for(int i=1;i<sp1.length-1;i++){ | |
// octAddress.append("."+sp1[i]); | |
//// System.out.println(i+": "+sp2[i]); | |
// } | |
// System.out.println(octAddress); | |
// System.out.println(sp1[sp1.length-1]); | |
System.out.println("========================2"); | |
// String[] sp2 = sp1[sp1.length].split(","); | |
// for(int i=0;i<sp1.length;i++){ | |
// } | |
// | |
//// sp1分割確認済み | |
// for(int i=0;i<sp1.length;i++){ | |
// System.out.println(i+": "+sp2[i]); | |
// } | |
// System.out.println("========================3"); | |
// | |
//// 分岐チェック | |
// for(int i=0;i<sp1.length;i++){ | |
// if(sp1[sp1.length-1].matches(".*,.*")){ | |
//// System.out.println(i+":"+sp1[i]+": あります"); | |
// String[] sp3 =sp1[sp1.length-1].split("-"); | |
// for(int j=0;j<sp3.length;j++){ | |
// System.out.println("sp3["+j+"]:"+sp3[j]); | |
// } | |
// } else { | |
// System.out.println(i+":"+sp1[i]+": ないです"); | |
// } | |
// } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment