Is it possible to download a file with JSON data inside it from a URL? Also, the files I need to get have no file extension, is this a problem or can i force it to have a .t
Basically you would do something like:
Code:
URL address = URL.parse("http://yoururlhere.com/yourfile.txt");
URLConnection conn = new URLConnection(address);
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer bab = new ByteArrayBuffer(64);
int current = 0;
while((current = bis.read()) != -1) {
bab.append((byte)current);
}
FileOutputStream fos = new FileOutputStream(new File(filepath));
fos.write(bab.toByteArray());
fos.close();