So, I need to access a list of released forge, sponge vanilla, and sponge forge versions, preferably through maven. I’m doing some testing with the below snippet of code:
public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException, TransformerException {
URL versions = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/maven-metadata.xml");
InputStream is = versions.openConnection().getInputStream();
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
is.close();
StringWriter writer = new StringWriter();
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(writer));
writer.close();
System.out.println(writer.toString());
}
and that produces the expected output. However, if I change the url to https://repo.spongepowered.org/maven/org/spongepowered/spongevanilla/maven-metadata.xml
or https://repo.spongepowered.org/maven/org/spongepowered/spongeforge/maven-metadata.xml
the following error is produced:
Exception in thread "main" com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:567)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1896)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.java:1761)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1799)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:156)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at Test.main(Test.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
I have checked out all three documents with chrome’s view-source, and I cannot find any noticeable differences. I have tried reading the url source into a byte array and then putting it in a string, using an InputStreamReader, and just plain printing the content of the document. From this, I have discovered that the two repo.spongepowered url’s seem to produce many unrecognizable characters, yet, chrome can still read them just fine. Does anyone know what could be going wrong? Thanks for any help!