Reputation: 1
public class WriteToFile {
private static final String ELEMENT_CONFIGURATION_LIST_MARSHALLER = "elementConfigurationListMarshaller";
public static void main(String args[]) {
try {
for (String input : args) {
System.out.println(getHashFromXml(input));
}
} catch (IOException e) {
System.out.println(e.getLocalizedMessage());
}
}
private static String getHashFromXml(String value) throws IOException {
SHA256Hashing calculatedHash = new SHA256Hashing();
BufferedReader br = Files.newBufferedReader(Paths.get(value));
String line;
boolean xmlHashRemoved = false;
while ((line = br.readLine()) != null) {
if (!xmlHashRemoved) {
int tagIndex = line
.indexOf('<' + ELEMENT_CONFIGURATION_LIST_MARSHALLER);
if (tagIndex >= 0) {
line = line.replaceFirst('<'
+ ELEMENT_CONFIGURATION_LIST_MARSHALLER + " .*"
+ '>',
'<' + ELEMENT_CONFIGURATION_LIST_MARSHALLER + '>');
xmlHashRemoved = true;
}
}
calculatedHash.update(line + '\n');
}
return calculatedHash.toString();
}
}
1) Eclipse: Output "583427bc82815de1ce1d22bc54a4c879f98f00cb3c91b3be8ede85cd40831b98" 2) java -cp FileReader.jar WriteToFile.jar C:/WC/10.3/66830/Export_admin_202005260846.xml: "8e9bdbf9aec3c9b4be3879c3b352eacc31960c9f718e391142ab819644a525a9"
Code and input are the same but the output is different.
Upvotes: 0
Views: 126
Reputation: 509
I hope this will help you manage your dependency accordingly
java -cp /etc/hadoop/conf:/etc/hadoop/conf/log4j.properties:./conf:x.jar:myjar.jar com.mycom.WriteToFile
Upvotes: 0