Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions 07-java-io/task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
package com.example.task01;

import java.io.IOException;
import java.io.InputStream;

public class Task01Main {
public static void main(String[] args) throws IOException {
public class Task01Main
{
public static void main(String[] args) throws IOException
{
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:

/*
System.out.println(checkSumOfStream(new ByteArrayInputStream(new byte[]{0x33, 0x45, 0x01})));
*/

}

public static int checkSumOfStream(InputStream inputStream) throws IOException {
public static int checkSumOfStream(InputStream inputStream) throws IOException
{
// your implementation here
return 0;
if (inputStream == null)
{
throw new IllegalArgumentException();
}
int checkSum = 0;
int stream_byte = inputStream.read();
while (stream_byte != -1)
{
checkSum = Integer.rotateLeft(checkSum, 1) ^ stream_byte;
stream_byte = inputStream.read();
}
return checkSum;
}
}
}