mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-16 10:17:23 +00:00
ICU-6250 Add function for reading ScriptAndLanguage file
X-SVN-Rev: 24634
This commit is contained in:
parent
8081e1c652
commit
407b86c66a
1 changed files with 57 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -15,11 +15,16 @@ import java.io.PrintStream;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.io.*;
|
||||
import java.util.Scanner;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
public class ModuleWriter
|
||||
{
|
||||
private static final String BUILDER_FILE_PATH="src/com/ibm/icu/dev/tool/layout/";
|
||||
|
||||
public ModuleWriter()
|
||||
{
|
||||
wroteDefine = false;
|
||||
|
@ -30,7 +35,7 @@ public class ModuleWriter
|
|||
try
|
||||
{
|
||||
output = new PrintStream(
|
||||
new FileOutputStream(outputFileName));
|
||||
new FileOutputStream(BUILDER_FILE_PATH+outputFileName));
|
||||
} catch (IOException e) {
|
||||
System.out.println("? Could not open " + outputFileName + " for writing.");
|
||||
return;
|
||||
|
@ -97,7 +102,56 @@ public class ModuleWriter
|
|||
protected boolean wroteDefine;
|
||||
|
||||
protected PrintStream output;
|
||||
|
||||
|
||||
protected BufferedReader reader;
|
||||
protected Scanner sc;
|
||||
protected PrintStream updateFile;
|
||||
protected int previousTotalScripts;
|
||||
protected int previousTotalLanguages;
|
||||
protected ArrayList scriptVersionNumber = new ArrayList();
|
||||
protected ArrayList languageVersionNumber = new ArrayList();
|
||||
|
||||
public void openScriptAndLanguages(String name){
|
||||
try
|
||||
{
|
||||
updateFile = new PrintStream(new FileOutputStream(BUILDER_FILE_PATH+name));
|
||||
} catch (IOException e) {
|
||||
System.out.println("? Could not open " + name + " for writing.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void readFile(String file, String what){
|
||||
try
|
||||
{
|
||||
reader = new BufferedReader(new FileReader(BUILDER_FILE_PATH+file));
|
||||
String inputText = "";
|
||||
String versionToAdd = "";
|
||||
while((inputText=reader.readLine())!=null){
|
||||
if(what.equals("script") && inputText.contains("Script=")){
|
||||
previousTotalScripts = Integer.parseInt(inputText.substring(inputText.indexOf("=")+1));
|
||||
}else if(what.equals("languages") && inputText.contains("Language=")){
|
||||
previousTotalLanguages = Integer.parseInt(inputText.substring(inputText.indexOf("=")+1));
|
||||
}else if(what.equals("script") && inputText.contains("Scripts={")){
|
||||
while(!(versionToAdd=reader.readLine()).contains("}")){
|
||||
scriptVersionNumber.add(versionToAdd);
|
||||
}
|
||||
}else if(what.equals("languages") && inputText.contains("Languages={")){
|
||||
while(!(versionToAdd=reader.readLine()).contains("}")){
|
||||
languageVersionNumber.add(versionToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("? Could not open " + file + " for reading.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static final String moduleHeader =
|
||||
"/*\n" +
|
||||
" *\n" +
|
||||
|
|
Loading…
Add table
Reference in a new issue