Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
Caracteres extraños agregados al principio del archivo en Hadoop

Cada vez que creo un nuevo archivo en Hadoop usando Java y escribo el contenido, se agregan caracteres especiales al principio del archivo. ¿Hay alguna forma de eliminar? A continuación se muestra el código

 TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(document), new StreamResult(writer)); String extractedXML = writer.getBuffer().toString().replaceAll("\\r$", ""); FSDataOutputStream fin = fs.create("/filelocation/input.txt"); fin.writeUTF(extractedXML); fin.close(); $ hadoop fs -cat /filelocation/input.txt|head -5 )▒hello world input1 hello again hello welcome again
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Funcionó para mí, simplemente reemplazando las líneas a continuación

 FSDataOutputStream fin = fs.create("/filelocation/input.txt"); fin.writeUTF(extractedXML); fin.close();

con el siguiente código:

 OutputStream os = fs.create( "/filelocation/input.txt", new Progressable() { public void progress() { } }); BufferedWriter br = new BufferedWriter( new OutputStreamWriter( os, "UTF-8" ) ); br.write(extractedXML); br.close();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda