Difference between revisions of "Statistical Algorithms Importer: Java Project FAQ"

From Gcube Wiki
Jump to: navigation, search
(Main Class)
Line 9: Line 9:
 
The first parameter of a Java process is the main class that will be executed. Please note the full package name must be entered as default value, for example:
 
The first parameter of a Java process is the main class that will be executed. Please note the full package name must be entered as default value, for example:
 
*org.d4science.projectx.XClass
 
*org.d4science.projectx.XClass
 +
 +
 +
== How Use File Input ==
 +
 +
 +
:Java code in sample:
 +
 +
<pre style="display:block;font-family:monospace;white-space:pre;margin:1em 0;">
 +
package org.myfactory.specialgroup;
 +
 +
import java.nio.file.Files;
 +
import java.nio.file.Path;
 +
import java.nio.file.Paths;
 +
import java.nio.file.StandardCopyOption;
 +
 +
 +
 +
/**
 +
*
 +
* @author Giancarlo Panichi
 +
*
 +
*/
 +
public class FileConsumer {
 +
 +
public static void main(String[] args) {
 +
try {
 +
Path fileInput=Paths.get(args[0]);
 +
Path fileOutput=Paths.get("output.txt");
 +
Files.copy(fileInput, fileOutput, StandardCopyOption.REPLACE_EXISTING);
 +
 +
} catch (Throwable e) {
 +
System.out.println("Error in process: " + e.getLocalizedMessage());
 +
e.printStackTrace();
 +
}
 +
}
 +
 +
}
 +
</pre>
 +
  
 
[[Category:Statistical Algorithms Importer]]
 
[[Category:Statistical Algorithms Importer]]

Revision as of 18:18, 19 October 2017

F.A.Q. of Statistical Algorithms Importer (SAI), here are common mistakes we have found in Java Project.


Main Class

The first parameter of a Java process is the main class that will be executed. Please note the full package name must be entered as default value, for example:

  • org.d4science.projectx.XClass


How Use File Input

Java code in sample:
package org.myfactory.specialgroup;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;



/**
 * 
 * @author Giancarlo Panichi
 *
 */
public class FileConsumer {
	
	public static void main(String[] args) {
		try {
			Path fileInput=Paths.get(args[0]);
			Path fileOutput=Paths.get("output.txt");
			Files.copy(fileInput, fileOutput, StandardCopyOption.REPLACE_EXISTING);
			
		} catch (Throwable e) {
			System.out.println("Error in process: " + e.getLocalizedMessage());
			e.printStackTrace();
		}
	}

}