我正在尝试从S3读取csv文本文件,然后将其每个行发送到分布式队列以进行处理.
当试图读取它时,我得到“java.net.SocketException:Socket is closed”正在读取的文件的不同点的异常(在不同的执行中).这是代码:
AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(MyClass.class.getResourceAsStream("myCredentials.properties"))); String bucketName = "myBucket"; String key = "myFile"; S3Object object = s3.getObject(new GetObjectRequest(bucketName,key)); InputStream in = object.getObjectContent(); BufferedReader readerS3 = new BufferedReader(new InputStreamReader(in,Charset.forName(fileInfo.getEncoding()))); try { String line = null; while ((line = readerS3.readLine()) != null) { // Sending the line to a distributed queue } } catch (IOException e) { e.printStackTrace(); }finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } }
有关如何解决这个问题的任何想法?
更新: