private List<Tag<?>> readRawNBT(File f, boolean compressed) { List<Tag<?>> tags = new ArrayList<Tag<?>>(); try { InputStream is = new FileInputStream(f); NBTInputStream ns = new NBTInputStream(is, compressed); try { boolean eof = false; while (!eof) { try { tags.add(ns.readTag()); } catch (EOFException e) { eof = true; } } } finally { try { ns.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Unable to close file", "File Read Error", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(this, "Unable to open file", "File Read Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { return null; } return tags; }
private List<Tag<?>> readRawNBT(File f, boolean compressed) { List<Tag<?>> tags = new ArrayList<Tag<?>>(); try { InputStream is = new FileInputStream(f); NBTInputStream ns = new NBTInputStream(is, compressed); try { boolean eof = false; while (!eof) { try { tags.add(ns.readTag()); } catch (EOFException e) { eof = true; } } } finally { try { ns.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Unable to close file", "File Read Error", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(this, "Unable to open file", "File Read Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { return null; } return tags; }
private List<Tag<?>> readRawNBT(File f, boolean compressed) { List<Tag<?>> tags = new ArrayList<Tag<?>>(); try { InputStream is = new FileInputStream(f); NBTInputStream ns = new NBTInputStream(is, compressed); try { boolean eof = false; while (!eof) { try { tags.add(ns.readTag()); } catch (EOFException e) { eof = true; } } } finally { try { ns.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Unable to close file", "File Read Error", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(this, "Unable to open file", "File Read Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { return null; } return tags; }
ns.close(); } catch (IOException ioe) {
ns.close(); } catch (IOException ioe) {
ns.close(); } catch (IOException ioe) {
public ServerInfo[] loadServers() throws Exception{ final FileInputStream fis = new FileInputStream(file); NBTInputStream nbtIs = new NBTInputStream(fis, false); // the cast should be safe, because compound tag is also a root container of contents in the file... final CompoundTag root = (CompoundTag) nbtIs.readTag(); nbtIs.close(); ListTag serversListTag = (ListTag) root.getValue().get("servers"); if(serversListTag.getElementType() != CompoundTag.class) { throw new Exception("Type of list value in servers file is not tag_compound!"); } List<CompoundTag> serversList = serversListTag.getValue(); ServerInfo[] result = new ServerInfo[serversList.size()]; for(int i = 0; i < serversList.size(); ++i){ result[i] = createServerFromTag(serversList.get(i).getValue()); } return result; }