"Frankenstein-ed"Java의 첫 번째 부분은 완벽하게 작동하지만 두 번째 부분은 혼란스러운 말도 안되는 내용을 출력합니다. 결과의 변수는 사용자로부터의 입력입니다. 나는 당신이 Database/Analysis 배경에서 왔을 때 당신이 몇 초안에 뭔가를하고 오류가 발생하지 않는다는 것을 알기가 어려울 때, 나는 어리석은 이유 때문에 파싱을하기 전에 문자열을 먼저 UpperCase해야만했다. 나는 신용이 만기가되는 곳에 신용을 주었다. 코드 ...구문 분석 문자열 파일로 출력
MYFILE.TXT ---> [Ljava.lang.String 내에서, 19821f
import java.io.*;
/*http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29*/
public class StringParser {
public static void main (String arg[])
throws FileNotFoundException {
String result = "eggs toast bacon bacon butter ice beer".toUpperCase();
String[] resultU = result.split("\\s");
String[] y = resultU;
{
for (int x=0; x< resultU.length; x++)
System.out.println(resultU[x]);
/*http://www.javacoffeebreak.com/java103/java103.html#output*/
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try
{
// Create a new file output stream
// connected to "myfile.txt"
out = new FileOutputStream("myfile.txt");
// Connect print stream to the output stream
p = new PrintStream(out);
p.println (resultU);
p.close();
}
catch (Exception e)
{
System.err.println ("Error writing to file");
}
}
}
}
저는 자바에 익숙하지 않아서 불을 피우면서 배우려고합니다 ... :) 고마워요. 그것을 시험해 보도록하겠습니다 ... – Darren
cool thanks H.D.! – Darren
@Darren 그러면 정답으로 선택해야합니다.) –