Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 11th, 2013  |  syntax: Java  |  size: 1.03 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package valkryst.area;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.io.InputStreamReader;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10.  
  11. public class AreaLoader {
  12.         public static List<String> map = new ArrayList<String>();
  13.        
  14.         public void loadMapFromFile(final int mapID) {
  15.                 InputStream is = this.getClass().getClassLoader().getResourceAsStream("Areas/Area" + mapID + ".txt");
  16.                 try {
  17.                         BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
  18.                 String line = null;
  19.                 while ((line = bufferedReader.readLine()) != null) {
  20.                     map.add(line);
  21.                 }
  22.                 bufferedReader.close();
  23.                 } catch (FileNotFoundException e) {
  24.                         e.printStackTrace();
  25.                 } catch (IOException e) {
  26.                         e.printStackTrace();
  27.                 }
  28.                 System.out.println("Sucessfully finished loading Areas/Area" + mapID + ".txt");
  29.         }
  30.  
  31.         public static String[] toArray() {
  32.                 return map.toArray(new String[map.size()]);
  33.         }
  34. }