Disini ilmu yang ku dapatkan yaitu contains.
package com.andia.aryandie.latihan.parser;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
/**
* outputnya
* sawal
* anas
* Dendy
* Depok
*
* @author dendy
*
*/
public class TugasSawal2 {
public static void main(String[] args) {
String filename = "/home/dendy/test.txt";
File file = new File(filename);
try {
FileReader fileReader = new FileReader(file);
BufferedReader reader = new BufferedReader(fileReader);
String line = "";
try {
while ((line = reader.readLine()) != null) {
if (line.contains("")) {
System.out.println(line.substring(8, 13));
}if (line.contains("")) {
System.out.println(line.substring(10, 15));
}
}
} catch (Exception e) {
}
} catch (Exception e) {
}
}
}
System.out.println(line.substring(8, 13));
}if (line.contains("
System.out.println(line.substring(10, 15));
}
}
} catch (Exception e) {
}
} catch (Exception e) {
}
}
}
outputnya :
Sawal
anas<
Dendy
Depok
anas<
Dendy
Depok
1 comment:
bisa juga menggunakan replace all di codingan diatas.untuk menggatikan contains..dan mungkin lebih gampang..
Post a Comment