Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alekseytimoshchenko/60f65e1d3300659e5fc3389534d259f2 to your computer and use it in GitHub Desktop.
Save alekseytimoshchenko/60f65e1d3300659e5fc3389534d259f2 to your computer and use it in GitHub Desktop.
import java.io.*;
public class Solution
{
public static void main(String[] args) throws IOException
{
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final String originalFile = br.readLine();
final String resultFile = br.readLine();
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(originalFile));
final BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(resultFile));
while (bis.available() > 0){
final byte[] buffer = new byte[bis.available()];
final int count = bis.read(buffer);
bos.write(getResultByte(buffer));
}
br.close();
bis.close();
bos.close();
}
private static byte[] getResultByte(byte[] bytes){
final String[] stringArray = new String(bytes).split(" ");
final StringBuilder sb = new StringBuilder();
for (String value : stringArray)
{
final double aDouble = Double.valueOf(value);
final long l = Math.round(aDouble);
final String valueOf = String.valueOf(l);
sb.append(valueOf);
sb.append(" ");
}
final String toString = sb.toString();
final byte[] resultBytes = toString.getBytes();
return resultBytes;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment