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
//============================================================================= | |
//=== Copyright (C) 2001-2013 Food and Agriculture Organization of the | |
//=== United Nations (FAO-UN), United Nations World Food Programme (WFP) | |
//=== and United Nations Environment Programme (UNEP) | |
//=== | |
//=== This program is free software; you can redistribute it and/or modify | |
//=== it under the terms of the GNU General Public License as published by | |
//=== the Free Software Foundation; either version 2 of the License, or (at | |
//=== your option) any later version. | |
//=== |
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
val username = "myusername" | |
val password = "mypassword".toCharArray() | |
class MyAuthenticator extends Authenticator { | |
def getPasswordAuthentication = | |
new PasswordAuthentication(kuser, password); | |
} | |
Authenticator.setDefault(new MyAuthenticator()); |
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
// Option 1. Simplest and could be the first implementation | |
trait ReadBytes { | |
protected def resource: InputStreamResource | |
def readHead(bytesCount: Long): Array[Byte] = { | |
val arr = new Array[Byte](bytesCount) | |
// I can do better but not worrying about it now | |
resource.acquireFor(_.read(arr)) | |
arr | |
} |