Skip to content

Commit

Permalink
Refactorización
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbh committed Oct 6, 2019
1 parent a6033bf commit 80aa109
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
17 changes: 7 additions & 10 deletions src/main/java/org/tecnificados/com/lector/App.java
Expand Up @@ -13,37 +13,34 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tecnificados.com.lector.util.Messages;

/**
* Lector de ficheros linea a linea
*/
public class App
{
private static final String UTF_8 = "utf-8";

private static final String CONF_PROPERTIES = "conf.properties";

private static final String PATH_TO_FILE = "pathToFile";

private static final Logger log = LoggerFactory.getLogger(App.class);

private static String filePath="fichero.txt";


private static void configuration() {
Properties prop = new Properties();
try
{
InputStream input = new FileInputStream(CONF_PROPERTIES);
InputStream input = new FileInputStream(Constant.CONF_PROPERTIES);
prop.load(input);
}
catch (IOException ex) {
log.error(Messages.getString("App.3"),ex);
}

if (prop.getProperty(PATH_TO_FILE)!=null) {
filePath=prop.getProperty(PATH_TO_FILE);
if (prop.getProperty(Constant.PATH_TO_FILE)!=null) {
Constant.filePath=prop.getProperty(Constant.PATH_TO_FILE);
}else {
log.info(PATH_TO_FILE+Messages.getString("App.4")+CONF_PROPERTIES);
log.info(Constant.PATH_TO_FILE+Messages.getString("App.4")+Constant.CONF_PROPERTIES);
}

}
Expand All @@ -59,7 +56,7 @@ public static void main( String[] args )

List<String> readedLines = new ArrayList<String>();
try {
readedLines = FileUtils.readLines(new File(filePath),UTF_8);
readedLines = FileUtils.readLines(new File(Constant.filePath),Constant.UTF_8);
log.info(Messages.getString("App.7")+readedLines.size());

} catch (IOException e) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/tecnificados/com/lector/Constant.java
@@ -0,0 +1,13 @@
package org.tecnificados.com.lector;

public class Constant {

public static final String UTF_8 = "utf-8";

public static final String CONF_PROPERTIES = "conf.properties";

public static final String PATH_TO_FILE = "pathToFile";

public static String filePath="fichero.txt";

}
@@ -1,11 +1,11 @@
package org.tecnificados.com.lector;
package org.tecnificados.com.lector.util;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class Messages {
private static final String BUNDLE_NAME = "org.tecnificados.com.lector.messages"; //$NON-NLS-1$
private static final String BUNDLE_NAME = "org.tecnificados.com.lector.util.messages";

private static ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);

Expand Down

0 comments on commit 80aa109

Please sign in to comment.