我的文字这个
sirket;sehir;ilce;unvan;numara
AKSA SAT VE PAAMA ANM RKET KADY BES;STANBUL;KADIKY;A.S.;1230488;
KER BV SANAY;STANBUL;ZEYTNBURNU;A:S.;308133;
C.E.S.COSKUN MH.N.ELK.DAY.TK.MAL.VE GIDA TC.LTD.T.;HATAY;SKENDERUN;LTD. T.;14947;
ANLU GAZ TCARET VE SANY ANNM RKET KIRIKKALE UBES;KIRIKKALE;KIRIKKALE;A.S.;12519;
BVR GIDA MARİ NAAT TURZM SANAY VE TCARET LTD.T.;STANBUL;LO;LTD:STİ.;239;
ASA AKRLK KMYA SANAY (YALOVA UBES);YALOVA;FTLKKY;A.S.;551484;
WNCOR NXDORF LGSAYR SSTEER A.S.-ESNLER SUES;STANBUL;ESENLER;-;1027;
DESA DER SAN. VE TC.;STANBUL;BAKIRKY;A.S.;1480;
SNTM BLŞM TEKJLER SAN. VE TC;DYARBAKIR;YENEHR;A.S.;1439;
我要变化 ”。” 字符而不是“:”仅在包含 AS ,LTD.T.,LTD:STİ 的 unvan 列中。等等。当java读取文本时我删除第一行。我给第一行不稳定。我想在改变之前写,改变之后但是我的代码有问题它不能写文本,因为我认为sirket列的空间。我怎么写。
我想要这个输出
KER BV SANAY;STANBUL;ZEYTNBURNU;A:S.;3083;
KER BV SANAY;STANBUL;ZEYTNBURNU;A.S.;308133;
BULVAR GIDA MAMLLERİ NAAT TURZM SANAY VE TCARET LTD.T.;STANBUL;LO;LTD:STİ.;2149;
BULVAR GIDA MAMLLERİ NAAT TURZM SANAY VE TCARET LTD.T.;STANBUL;LO;LTD.STİ.;239;
我的代码是
public class MaliyeBir {
private static String inputPath = "C:\\deneme\\Maliye.csv";
private static String outputPath = "C:\\yazdirilan\\YazdirilanMaliye.csv";
private static BufferedReader bufferedReader;
private static PrintWriter printWriter;
public static void main(String[] args) {
try {
FileInputStream inputStream = new FileInputStream(inputPath);
Reader reader = new InputStreamReader(inputStream, "ISO-8859-9");
bufferedReader = new BufferedReader(reader);
FileOutputStream outputStream = new FileOutputStream(outputPath);
Writer writer = new OutputStreamWriter(outputStream, "ISO-8859-9");
printWriter = new PrintWriter(writer);
String line;
while ((line = bufferedReader.readLine()) != null) {
EndeksDegeri eD;
eD = lineToClass(line);
if (shouldOutput(eD)) {
printWriter.append(classToLine(eD, true));
printWriter.append(classToLine(eD, false));
}
}
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
bufferedReader.close();
printWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static boolean shouldOutput(EndeksDegeri eD) {
if (!eD.tip.contains(":")) {
return false;
}
return true;
}
private static String classToLine(EndeksDegeri eD, boolean original) {
if (!original) {
eD.tip = eD.tip.replace(":", ".");
}
return eD.sirket.concat(";")
.concat(eD.sehir).concat(";")
.concat(eD.ilce).concat(";")
.concat(eD.tip).concat(";")
.concat(String.valueOf(eD.numara)
.concat("\r\n"));
}
private static EndeksDegeri lineToClass(String line) {
String[] element = line.split(";");
EndeksDegeri endeksDegeri = new EndeksDegeri();
endeksDegeri.sirket = element[0];
endeksDegeri.sehir = element[1];
endeksDegeri.ilce = element[2];
endeksDegeri.tip = element[3];
endeksDegeri.numara = Integer.valueOf(element[4]);
return endeksDegeri;
}