0

I have an xml file as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<billFile fileName=".dat" hasHeader="false" fieldDelimiter="    "/>

The fieldDelimiter contains a tab. When I call Unmarshaller.unmarshal to convert this xml file to an object, the tab gets replaced by a space. I want it to stay as a tab. Here is the java code I have:

import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;


public class XMLToConfig
{
  public static void main(String[] args) throws JAXBException
  {
    String input                  = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>    <billFile fileName=\".dat\" hasHeader=\"false\" fieldDelimiter=\" \"/>";
    JAXBContext jaxbContext       = JAXBContext.newInstance(BillFile.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    BillFile bf                 = (BillFile)jaxbUnmarshaller.unmarshal(new StreamSource(new StringReader(input), "UTF8"));
  }
}
Wael
  • 1,533
  • 4
  • 20
  • 35

1 Answers1

1

You have to use the Unicode of tab instead of a real tab:

unicode for tab and sapce

Community
  • 1
  • 1
Dimitrios Begnis
  • 823
  • 6
  • 16