Created
April 3, 2017 14:27
-
-
Save hugithordarson/017fb4c9a83cfd92c8674cc693f4c3c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package x; | |
import java.io.IOException; | |
import org.apache.poi.util.IOUtils; | |
import com.webobjects.appserver.WOActionResults; | |
import com.webobjects.appserver.WOApplication; | |
import com.webobjects.appserver.WORequest; | |
import com.webobjects.appserver.WOResponse; | |
import com.webobjects.foundation.NSArray; | |
import er.extensions.appserver.ERXDirectAction; | |
public class MavenResourceTestAction extends ERXDirectAction { | |
public MavenResourceTestAction( WORequest r ) { | |
super( r ); | |
} | |
public WOActionResults resourceAction() throws IOException { | |
System.out.println( "loadStringUsingWOResourceManager: " + loadStringUsingWOResourceManager() ); | |
System.out.println( "loadStringUsingJavaClassLoader: " + loadStringUsingJavaClassLoader() ); | |
return new WOResponse(); | |
} | |
private static String loadStringUsingWOResourceManager() throws IOException { | |
byte[] bytes = WOApplication.application().resourceManager().bytesForResourceNamed( "foo.txt", "SoloWeb", NSArray.emptyArray() ); | |
return new String( bytes, "utf-8" ); | |
} | |
private static String loadStringUsingJavaClassLoader() throws IOException { | |
byte[] bytes = IOUtils.toByteArray( MavenResourceTestAction.class.getClassLoader().getResourceAsStream( "foo.txt" ) ); | |
return new String( bytes, "utf-8" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment