이 코드는 html 파일 의 소스 코드를 다운로드하는 데 사용되지만 일부 줄은 건너 뜁니다. 그 이유는 무엇입니까? 그것은 다시 할당되기 전에java.net sourceCode reader skip lines
이String sourceCodeLine = s.readLine();
그런 sourceCodeLine
으로 아무것도 할 수 없다 : 당신이 밖으로 시작하기 때문에
import java.io.IOException;
import java.net.*;
import java.util.*;
import java.io.*;
public class downloadSource {
private URL url;
private URLConnection con;
// Construct the object with a new URL Object resource
downloadSource(String url) {
try {
this.url = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
// Returns an object instance
public BufferedReader SourceCodeStream() throws IOException {
return new BufferedReader(new InputStreamReader(this.url.openStream()));
}
public void returnSource() throws IOException, InterruptedException {
// FIX ENTRIE SOURCE CODE IS NOT BEING DWLOADED
// Instinate a new object by assigning it the returned object from
// the invoked SourceCodeStream method.
BufferedReader s = this.SourceCodeStream();
if(s.ready()) {
String sourceCodeLine = s.readLine();
Vector<String> linesOfSource = new Vector();
while(sourceCodeLine != null) {
sourceCodeLine = s.readLine();
linesOfSource.add(s.readLine());
}
Iterator lin = linesOfSource.iterator();
while(lin.hasNext()) {
}
}
}
}