동일한 문장을 복사 할 때까지 텍스트 파일 (일부 문장을 쓴 파일)에서 내용을 읽고 내용을 모두 인쇄하고 있습니다. PDF 파일에서, 아무 것도 콘솔에 출력되지 않아 빌드가 성공적으로 수행됩니다.자바에서 파일을 읽는 중
이 내 코드입니다 :
File f=new File("input.txt");
Scanner sc=new Scanner(f);
while (sc.hasNext())
{
String line=sc.nextLine();
int i=0;
while (i< line.length())
{
char c=line.charAt(i);
System.out.println(c);
i++;
}
}
sc.close();
텍스트 파일의 내용 (여부 나 자신에 의해 문장을 쓰거나 PDF에서 복사 할 때) :
{sample program in TINY language- computes factorial}
read x;{input an integer}
if 0<x then {don’t compute if x<=0}
fact:=1;
repeat
fact:=fact*x;
x:=x-1
무엇 오전 PDF 파일의 문장을 내가 읽는 텍스트 파일에 복사하고 싶다면 무엇을해야할까요?
'sc.hasNext()'를'sc.hasNextLine()'으로 변경하십시오. – DodgyCodeException