IDTstudios1
Programmer
I'm primarily a PHP and programmer, however a recent need to pull off a certain function has tossed me into the Java world. I found the snippet of code below on another thread. It does exactly what I need, I just have no clue on how to compile it.
I know enough to have download the Java SDK with NetBeans and have been trying to figure it out for several hours with no luck. I could always go buy a book or take a class but considering that this will probably be the only time I ever need to compile a java app it seemed best to just ask for help.
If someone could give me a step by step on how to make the code below usable in a compiled form I would greatly appreciate it.
Thanks,
Andrew
I know enough to have download the Java SDK with NetBeans and have been trying to figure it out for several hours with no luck. I could always go buy a book or take a class but considering that this will probably be the only time I ever need to compile a java app it seemed best to just ask for help.
If someone could give me a step by step on how to make the code below usable in a compiled form I would greatly appreciate it.
Code:
File f = new File("somefile.txt");
FileInputStream fis = new FileInputStream(f);
byte[] data = new byte[(int)f.length()];
fis.read(data);
fis.close();
String u = "[URL unfurl="true"]http://sync.foxysync.com/test.php?action=process&id=1";[/URL]
URL url = new URL(u);
HttpURLConnection huc = (HttpURLConnection)url.openConnection();
huc.setRequestMethod("POST");
huc.setDoOutput(true);
huc.setUseCaches(false);
huc.setFollowRedirects(true);
DataOutputStream dos = new DataOutputStream(huc.getOutputStream());
dos.write(data, 0, data.length);
dos.flush();
dos.close();
huc.disconnect();
Thanks,
Andrew