Currently, I have this:
String URL = "//Somewhere in my computer";
PrintWriter list = new PrintWriter(new FileWriter(URL, true));
Is it possible to write to an online site that has document? For example, there are sites where you only need the URL of the site to write in that document. Is it possible to read and edit such from an java program?
This is what I did for a TitanPad Service:
String someText = "Here goes magical text";
URL url = null;
try {
url = new URL("https://titanpad.com/3VBeN3Xo31");
} catch (MalformedURLException e) {
e.printStackTrace();
}
URLConnection connection = null;
try {
connection = url.openConnection();
} catch (IOException e) {
e.printStackTrace();
}
connection.setDoOutput(true);
OutputStream outStream = null;
try {
outStream = connection.getOutputStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
outStream.write(someText.getBytes(Charset.forName("UTF-8")));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
outStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
You can use FTP-
String someText = "Here goes magical text";
URL url = new URL("ftp://user:password@somewebsite.com/filename.txt");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
OutputStream outStream = connection.getOutputStream();
outStream.write(someText.getBytes(Charset.forName("UTF-8")));
outStream.close();