Skip to content

Commit

Permalink
Prevent possible resource leak
Browse files Browse the repository at this point in the history
  • Loading branch information
12emin34 committed Sep 14, 2020
1 parent 7e99347 commit 1ec1f4b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public void saveSchematic(Location[] locations, String owner, File file) {
@Override
public void pasteSchematic(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
byte[] blocks = nbt.getByteArray("Blocks");
byte[] data = nbt.getByteArray("Data");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand All @@ -73,13 +71,11 @@ public void pasteSchematic(File f, Location loc) {
public List<Location> getLocations(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
List<Location> locations = new ArrayList<>();
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public void saveSchematic(Location[] locations, String owner, File file) {
@Override
public void pasteSchematic(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
byte[] blocks = nbt.getByteArray("Blocks");
byte[] data = nbt.getByteArray("Data");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand All @@ -73,13 +71,11 @@ public void pasteSchematic(File f, Location loc) {
public List<Location> getLocations(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
List<Location> locations = new ArrayList<>();
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public void saveSchematic(Location[] locations, String owner, File file) {
@Override
public void pasteSchematic(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
byte[] blocks = nbt.getByteArray("Blocks");
byte[] data = nbt.getByteArray("Data");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand All @@ -73,13 +71,11 @@ public void pasteSchematic(File f, Location loc) {
public List<Location> getLocations(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
List<Location> locations = new ArrayList<>();
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public void saveSchematic(Location[] locations, String owner, File file) {
@Override
public void pasteSchematic(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
byte[] blocks = nbt.getByteArray("Blocks");
byte[] data = nbt.getByteArray("Data");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand All @@ -73,13 +71,11 @@ public void pasteSchematic(File f, Location loc) {
public List<Location> getLocations(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
List<Location> locations = new ArrayList<>();
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public void saveSchematic(Location[] locations, String owner, File file) {
@Override
public void pasteSchematic(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
byte[] blocks = nbt.getByteArray("Blocks");
byte[] data = nbt.getByteArray("Data");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand All @@ -73,13 +71,11 @@ public void pasteSchematic(File f, Location loc) {
public List<Location> getLocations(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
List<Location> locations = new ArrayList<>();
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public void saveSchematic(Location[] locations, String owner, File file) {
@Override
public void pasteSchematic(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
byte[] blocks = nbt.getByteArray("Blocks");
byte[] data = nbt.getByteArray("Data");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand All @@ -73,13 +71,11 @@ public void pasteSchematic(File f, Location loc) {
public List<Location> getLocations(File f, Location loc) {
loc = loc.subtract(2, 1, 2);
List<Location> locations = new ArrayList<>();
try {
FileInputStream fis = new FileInputStream(f);
try (FileInputStream fis = new FileInputStream(f)) {
NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
short width = nbt.getShort("Width");
short height = nbt.getShort("Height");
short length = nbt.getShort("Length");
fis.close();
//paste
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
Expand Down

0 comments on commit 1ec1f4b

Please sign in to comment.