This file contains 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
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.BufferedReader; | |
import java.net.URL; | |
class MyFileUtil { | |
/** | |
* PHPのfile_get_contentsもどき | |
* urlに指定されたページのHTMLを取得します |
This file contains 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
object CharacterCount { | |
// scala.collection.mutableをインポートしておけば、mutable.Mapの宣言が短くできる | |
// インポート無 → cala.collection.mutable.Map[Char, Int]() | |
// インポート有 → mutableMap[Char, Int]() | |
import scala.collection.mutable | |
/** | |
* 指定された文字列中に出現する各文字をカウントし、Mapに格納する | |
* @param text 出現する文字をカウントしたい文字列 |
This file contains 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
/** | |
* Scalaでファイルの入出力 | |
* Javaのクラスを使ってファイルを作成し、Scalaのクラスを使ってファイルを読み込む | |
*/ | |
object FileIO { | |
def main( args:Array[String] ) { | |
// JavaのFileOutputStreamクラスとOutputStreamWriterを別名でimport | |
// それぞれインスタンス生成時の1回のみの使用なので別名にする意味は特にないです。 | |
import java.io.{ FileOutputStream=>FileStream, OutputStreamWriter=>StreamWriter }; |
This file contains 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
#!/bin/bash | |
mkdir ./src | |
mkdir ./src/main | |
mkdir ./src/main/scala | |
mkdir ./src/main/java | |
mkdir ./src/main/resources | |
mkdir ./src/test | |
mkdir ./src/test/scala | |
mkdir ./src/test/java | |
mkdir ./src/test/resources |
This file contains 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
def fileName = "/tmp/groovy_io_sample.txt" | |
def encode = "UTF-8" | |
def file = new File(fileName) | |
// 存在確認 | |
if (file.exists()) { | |
println "not exists" | |
} else { | |
println "not exists" | |
} |
This file contains 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
// ******************************************* | |
// This is usage of Date object on Groovy2.1 | |
// Groovy2.1でのDateオブジェクトの使い方です。 | |
// ******************************************* | |
// Generate Date object.(Default TimeZone is "CET" in my computer) | |
// Dateオブジェクトの生成(私の環境ではデフォルトのタイムゾーンは"CET") | |
// sample of how to declare | |
// def sample = new Date() | |
// def sample = Date.parse("yyyy/MM/dd HH:mm:ss", "1985/02/20 12:34:56") |
This file contains 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
class WieMkString { | |
static String mkString(List self){ | |
mkString(self, "", "", "") | |
} | |
static String mkString(List self, String sep) { | |
mkString(self, "", sep, "") | |
} | |
static String mkString(List self, String start, String sep, String end) { |
This file contains 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
/********************************** | |
* sample of Set | |
**********************************/ | |
import groovy.transform.EqualsAndHashCode | |
@EqualsAndHashCode | |
class sample { | |
def age | |
} | |
def list1 = [ |
This file contains 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
test |
This file contains 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
拡張子のないファイルのテスト! | |
CETで20:00に更新 |
OlderNewer