Results 1 to 2 of 2
- 11-04-2011, 12:02 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
Writing to text file using an executable Jar
Hey guys I'm new here so sorry if this is supposed to be put somewhere else, but...
My friend and i have been trying to take a simple program of ours and make it an executable jar file so we can run it on multiple computers(obviously). The problem we have been having is whenever we export our program into a jar(via Eclipse) the jar file won't create/write to a text file. When I run the program normally through Eclipse and not the jar, it creates the text file and writes to it just fine so was wondering if i was doing something wrong...
And before anyone says anything about the retarded shuffle^^ i didn't write this my buddy knows nothing about Collections.shuffle(ArrayList) XDJava Code:import java.io.*; public class Main { public static void main(String[] args) { File file1 = new File(System.getProperty("user.home") + "\\Desktop\\Groups.txt"); String[] students = new String[]{"Hurley", "Trad", "Kelsey", "Colangelo", "Curry", "Bolton", "Horine", "Ruth", "Cardona", "Bacelli", "Bosko", "Brannon", "Delacruz", "Furlow", "Harden", "Humes", "Kolos", "Long", "Lowman", "Lundstrom", "Oliver", "Race", "Rodriguez", "Stokes", "Weld", "Windham"}; shuffle(students); int j = 1; try { BufferedWriter out = new BufferedWriter(new FileWriter(file1)); for (int i = 0; i<26; i+=2) { out.write(""+j+"\t"+students[i]+"\t\t\t"+students[i+1]); out.newLine(); j++; } out.close(); }catch (IOException e){ e.printStackTrace(); } } public static void exch(String[] a, int i, int j) { String swap = a[i]; a[i] = a[j]; a[j] = swap; } public static void shuffle(String[] a) { int N = a.length; for (int i = 0; i < N; i++) { int r = i + (int) (Math.random() * (N-i)); // between i and N-1 exch(a, i, r); } } }
- 11-04-2011, 06:20 AM #2
Similar Threads
-
Reading from a text file, then writing back to Text Area in Reverse
By medic642 in forum New To JavaReplies: 8Last Post: 07-17-2011, 02:38 PM -
Writing Text To A File
By loopsnhoops in forum New To JavaReplies: 15Last Post: 06-01-2011, 03:27 AM -
Writing into a text file
By africanhacker in forum New To JavaReplies: 3Last Post: 03-31-2011, 10:44 PM -
Im writing to a file and i want to skip lines while writing to a text file.
By Broden_McDonald in forum New To JavaReplies: 1Last Post: 02-27-2010, 01:29 AM -
writing text to file
By notwist in forum New To JavaReplies: 3Last Post: 04-25-2008, 04:20 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks