use of java.io.BufferedReader in project bazel by bazelbuild.
the class ResourceUsageAnalyzer method parseResourceTxtFile.
private void parseResourceTxtFile(Path rTxt, Set<String> resourcePackages) throws IOException {
BufferedReader reader = java.nio.file.Files.newBufferedReader(rTxt, UTF_8);
String line;
while ((line = reader.readLine()) != null) {
String[] tokens = line.split(" ");
ResourceType type = ResourceType.getEnum(tokens[1]);
for (String resourcePackage : resourcePackages) {
String owner = resourcePackage.replace('.', '/') + "/R$" + type.getName();
Pair<ResourceType, Map<String, String>> pair = resourceObfuscation.get(owner);
if (pair == null) {
Map<String, String> nameMap = Maps.newHashMap();
pair = Pair.of(type, nameMap);
}
resourceObfuscation.put(owner, pair);
}
if (type == ResourceType.STYLEABLE) {
if (tokens[0].equals("int[]")) {
model.addResource(ResourceType.DECLARE_STYLEABLE, tokens[2], null);
} else {
// TODO(jongerrish): Implement stripping of styleables.
}
} else {
model.addResource(type, tokens[2], tokens[3]);
}
}
}
use of java.io.BufferedReader in project bigbluebutton by bigbluebutton.
the class PEMReader method readFile.
/**
* Read the PEM file and save the DER encoded octet
* stream and begin marker.
*
* @throws IOException
*/
protected void readFile() throws IOException {
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
try {
while ((line = reader.readLine()) != null) {
if (line.indexOf(BEGIN_MARKER) != -1) {
beginMarker = line.trim();
String endMarker = beginMarker.replace("BEGIN", "END");
derBytes = readBytes(reader, endMarker);
return;
}
}
throw new IOException("Invalid PEM file: no begin marker");
} finally {
reader.close();
}
}
use of java.io.BufferedReader in project Japid by branaway.
the class BranLayoutCompilerTest method testHop.
@Test
public void testHop() throws IOException {
FileInputStream fis = new FileInputStream("JapidSample/app/japidviews/_layouts/Layout.html");
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String src = "";
for (String line = br.readLine(); line != null; line = br.readLine()) {
src += line + "\n";
}
JapidTemplate bt = new JapidTemplate("tag/Layout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
}
use of java.io.BufferedReader in project jvm-tools by aragozin.
the class TraceLoader method parseFrames.
public static StackFrame[] parseFrames(String trace) {
try {
List<StackFrame> frames = new ArrayList<StackFrame>();
BufferedReader br = new BufferedReader(new StringReader(trace));
while (true) {
String line = br.readLine();
if (line == null) {
break;
}
if (line.trim().length() > 0)
frames.add(StackFrame.parseTrace(line.trim()));
}
return frames.toArray(new StackFrame[frames.size()]);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of java.io.BufferedReader in project CoreNLP by stanfordnlp.
the class LinearClassifierFactory method loadFromFilename.
/**
* Given the path to a file representing the text based serialization of a
* Linear Classifier, reconstitutes and returns that LinearClassifier.
*
* TODO: Leverage Index
*/
public static LinearClassifier<String, String> loadFromFilename(String file) {
try {
BufferedReader in = IOUtils.readerFromString(file);
// Format: read indices first, weights, then thresholds
Index<String> labelIndex = HashIndex.loadFromReader(in);
Index<String> featureIndex = HashIndex.loadFromReader(in);
double[][] weights = new double[featureIndex.size()][labelIndex.size()];
int currLine = 1;
String line = in.readLine();
while (line != null && line.length() > 0) {
String[] tuples = line.split(LinearClassifier.TEXT_SERIALIZATION_DELIMITER);
if (tuples.length != 3) {
throw new Exception("Error: incorrect number of tokens in weight specifier, line=" + currLine + " in file " + file);
}
currLine++;
int feature = Integer.parseInt(tuples[0]);
int label = Integer.parseInt(tuples[1]);
double value = Double.parseDouble(tuples[2]);
weights[feature][label] = value;
line = in.readLine();
}
// First line in thresholds is the number of thresholds
int numThresholds = Integer.parseInt(in.readLine());
double[] thresholds = new double[numThresholds];
int curr = 0;
while ((line = in.readLine()) != null) {
double tval = Double.parseDouble(line.trim());
thresholds[curr++] = tval;
}
in.close();
LinearClassifier<String, String> classifier = new LinearClassifier<>(weights, featureIndex, labelIndex);
return classifier;
} catch (Exception e) {
throw new RuntimeIOException("Error in LinearClassifierFactory, loading from file=" + file, e);
}
}
Aggregations