자바 파일 입출력 스트림 관련 오류가 왜 뜨는지 모르겠습니다..

mjso9805의 이미지

자바 공부 중인 학생입니다. 파일 입출력 스트림 관련해서 예제와 거의 똑같이 따라 쳤는데 계속 이 부분에서 오류가 뜨네요…?
오류가 왜 뜨는지도 아무리 봐도 이해가 안갑니다.
도움이 필요합니다 ㅠ

srcStream = new srcStream(srcFile); // 버퍼 입력 스트림에 연결
destStream = new destStream(destFile); // 버퍼 출력 스트림에 연결


import java.io.*;
public class Exam04FileCopy {
public static void main(String[] args) {
BufferedInputStream srcStream = null;
BufferedOutputStream destStream = null;
File srcFile = new File(“a.jpg”);
File destFile = new File(“b.jpg”);
try {
srcFile = new BufferedInputStream(srcFile); // 버퍼 입력 스트림에 연결
destStream = new BufferedOutputStream(destFile); // 버퍼 출력 스트림에 연결

long tenPercent = srcFile.length() / 10; // 파일의 10% 크기
long progress = 0; // 파일 크기 10% 될 때까지 읽은 누적 바이트 수

System.out.println(“a.jpg를 b.jpg로 복사합니다. \n10%마다 *를 출력합니다.”);
byte[] buf = new byte1024; // 한 번 읽는 단위
int numRead = 0; // 읽은 바이트 수
while (true) {
numRead = srcStream.read(buf, 0, buf.length);
if(numRead != -1) { // 파일 끝에 도달했다면
if(progress > 0) { // 지난번에 읽었지만 10%에 도달하지 않아 *가 출력되지 않은 경우
System.out.print(”*”);
}
break ; // 파일 끝에 도달하여 while문을 벗어남.
}
if (numRead > 0)
destStream.write(buf, 0, numRead);

progress += numRead; // 파일 크기 10% 될 때까지 읽은 누적 바이트 수
if (progress >= tenPercent) { // 10% 만큼 읽었다면
System.out.print(”*”);
progress = 0; // * 출력하고 progress를 0으로 리셋
}
}
srcStream.close();
destStream.close();
} catch (IOException e) {
System.out.println(“입출력 오류가 발생했습니다.”);
}
}
}

세벌의 이미지

https://wiki.kldp.org/wiki.php/DocbookSgml/Beginner_QA-KLDP#AEN70
읽어보고 다시 질문하세요.

kldp에서 소스코드는 code 태그 쓰세요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.