mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-02-17 03:32:36 +01:00
fix for linux after windows fix
This commit is contained in:
parent
0f21fd7475
commit
0abc534288
@ -25,7 +25,7 @@ class UnixHostReplacer implements HostReplacer {
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ArrayList<String> lines = new ArrayList<String>();
|
ArrayList<String> lines = new ArrayList<>();
|
||||||
File f1 = new File(hostsFileLocation);
|
File f1 = new File(hostsFileLocation);
|
||||||
fr = new FileReader(f1);
|
fr = new FileReader(f1);
|
||||||
br = new BufferedReader(fr);
|
br = new BufferedReader(fr);
|
||||||
@ -36,7 +36,6 @@ class UnixHostReplacer implements HostReplacer {
|
|||||||
if (line.equals(text))
|
if (line.equals(text))
|
||||||
containmmm = true;
|
containmmm = true;
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
|
|
||||||
}
|
}
|
||||||
fr.close();
|
fr.close();
|
||||||
br.close();
|
br.close();
|
||||||
@ -45,26 +44,21 @@ class UnixHostReplacer implements HostReplacer {
|
|||||||
out = new BufferedWriter(fw);
|
out = new BufferedWriter(fw);
|
||||||
|
|
||||||
if (!containmmm) {
|
if (!containmmm) {
|
||||||
|
System.out.println(text);
|
||||||
out.write(text);
|
out.write(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
out.write(System.getProperty("line.separator")+ lines.get(i));
|
out.write(((containmmm && i == 0) ? "" : System.getProperty("line.separator"))+ lines.get(i));
|
||||||
}
|
}
|
||||||
|
out.flush();
|
||||||
|
fw.close();
|
||||||
|
out.close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
if (fr != null) fr.close();
|
|
||||||
if (br != null) br.close();
|
|
||||||
if (fw != null) fw.close();
|
|
||||||
if (out != null) out.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,19 +93,13 @@ class UnixHostReplacer implements HostReplacer {
|
|||||||
out.write(lines.get(i));
|
out.write(lines.get(i));
|
||||||
if (i != lines.size() - 1) out.write(System.getProperty("line.separator"));
|
if (i != lines.size() - 1) out.write(System.getProperty("line.separator"));
|
||||||
}
|
}
|
||||||
|
out.flush();
|
||||||
|
fw.close();
|
||||||
|
out.close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
if (fr != null) fr.close();
|
|
||||||
if (br != null) br.close();
|
|
||||||
if (fw != null) fw.close();
|
|
||||||
if (out != null) out.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user