Skip to content
Snippets Groups Projects
Commit 2f47e053 authored by Dott. Federico Volpini's avatar Dott. Federico Volpini
Browse files

removed nio imports and fixed code for compatibility with Java6

parent 155c7548
No related branches found
No related tags found
No related merge requests found
package org.universaal.tools.packaging.tool.actions;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
......@@ -27,7 +25,6 @@ import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.universaal.tools.packaging.tool.api.WizardDialogMod;
import org.universaal.tools.packaging.tool.gui.GUI;
import org.universaal.tools.packaging.tool.util.ConfigProperties;
import org.universaal.tools.packaging.tool.util.Configurator;
/**
......@@ -64,15 +61,18 @@ public class MPAaction extends AbstractHandler {
if(tryRecover){
try{
String content = readFile(recParts, StandardCharsets.UTF_8);
String[] segments = content.split(System.getProperty("line.separator"));
//System.out.println(segments[segments.length-1]);
for(int i = 0; i < segments.length; i++){
if(!segments[i].trim().isEmpty()){
System.out.println("Importing part "+segments[i]);
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(segments[i]);
FileInputStream fis = new FileInputStream(recParts);
BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
String line = reader.readLine();
while(line != null){
if(!line.trim().isEmpty()){
System.out.println("Importing part "+line);
IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(line);
parts.add(container.getProject());
}
line = reader.readLine();
}
this.recovered = true;
} catch (IOException e){
......@@ -131,9 +131,4 @@ public class MPAaction extends AbstractHandler {
return null;
}
private static String readFile(String path, Charset encoding) throws IOException {
byte[] encoded = Files.readAllBytes(Paths.get(path));
return encoding.decode(ByteBuffer.wrap(encoded)).toString();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment